/* * Reference arithmetic coding * Copyright (c) Project Nayuki * * https://www.nayuki.io/page/reference-arithmetic-coding * https://github.com/nayuki/Reference-arithmetic-coding */ /// /// A table of symbol frequencies. The table holds data for symbols numbered from 0 /// to getSymbolLimit()−1. Each symbol has a frequency, which is a non-negative integer. /// Frequency table objects are primarily used for getting cumulative symbol /// frequencies. These objects can be mutable depending on the implementation. /// The total of all symbol frequencies must not exceed Integer.MAX_VALUE. /// public interface FrequencyTable { /// /// Returns the number of symbols in this frequency table, which is a positive number. /// the number of symbols in this frequency table int SymbolLimit {get;} /// /// Returns the frequency of the specified symbol. The returned value is at least 0. /// the symbol to query /// the frequency of the symbol /// if the symbol is out of range int get(int symbol); /// /// Sets the frequency of the specified symbol to the specified value. /// The frequency value must be at least 0. /// the symbol to set /// the frequency value to set /// if the frequency is negative or the symbol is out of range /// if an arithmetic overflow occurs void set(int symbol, int freq); /// /// Increments the frequency of the specified symbol. /// the symbol whose frequency to increment /// if the symbol is out of range /// if an arithmetic overflow occurs void increment(int symbol); /// /// Returns the total of all symbol frequencies. The returned value is at /// least 0 and is always equal to {@code getHigh(getSymbolLimit() - 1)}. /// the total of all symbol frequencies int Total {get;} /// /// Returns the sum of the frequencies of all the symbols strictly /// below the specified symbol value. The returned value is at least 0. /// the symbol to query /// the sum of the frequencies of all the symbols below {@code symbol} /// if the symbol is out of range int getLow(int symbol); /// /// Returns the sum of the frequencies of the specified symbol /// and all the symbols below. The returned value is at least 0. /// the symbol to query /// the sum of the frequencies of {@code symbol} and all symbols below /// if the symbol is out of range int getHigh(int symbol); }