KiCad PCB EDA Suite
Loading...
Searching...
No Matches
context_manager.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Mark Roszko <[email protected]>
3 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
4 * Copyright (C) 2007 Ecma International (original Java source)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * License info found here:
19 * https://www.loc.gov/preservation/digital/formats/fdd/fdd000491.shtml
20 */
21
22#pragma once
23
24#include <cstdint>
25#include <vector>
27
28namespace U3D
29{
48{
49public:
51
57 void AddSymbol( uint32_t aContext, uint32_t aSymbol );
58
62 uint32_t GetSymbolFrequency( uint32_t aContext, uint32_t aSymbol );
63
70 uint32_t GetCumulativeSymbolFrequency( uint32_t aContext, uint32_t aSymbol );
71
77 uint32_t GetTotalSymbolFrequency( uint32_t aContext );
78
85 uint32_t GetSymbolFromFrequency( uint32_t aContext, uint32_t symbolFrequency );
86
87private:
88 std::vector<std::vector<std::uint32_t>> m_symbolCount;
89 std::vector<std::vector<std::uint32_t>> m_cumulativeCount;
90
94 const uint32_t m_elephant;
102 const uint32_t m_arraySizeIncr;
103};
104
105} // namespace U3D
uint32_t GetSymbolFrequency(uint32_t aContext, uint32_t aSymbol)
Get the number of occurrences of the given symbol in the context.
const uint32_t m_arraySizeIncr
the ammount to increase the size of an array when reallocating an array.
uint32_t GetSymbolFromFrequency(uint32_t aContext, uint32_t symbolFrequency)
Find the symbol in a histogram that has the specified cumulative frequency.
uint32_t GetTotalSymbolFrequency(uint32_t aContext)
Get the total occurrences of all the symbols in this context.
std::vector< std::vector< std::uint32_t > > m_cumulativeCount
uint32_t GetCumulativeSymbolFrequency(uint32_t aContext, uint32_t aSymbol)
Get the total number of occurrences for all symbols less than the given symbol in the context.
std::vector< std::vector< std::uint32_t > > m_symbolCount
void AddSymbol(uint32_t aContext, uint32_t aSymbol)
Add an occurrence of the symbol to the specified context.
const uint32_t m_maximumSymbolInHistogram
the maximum value that is stored in a histogram
const uint32_t m_elephant
Elephant determines the number of symbol occurences that are stored in each histogram.