cz.cuni.jagrlib.iface
Interface WheelOfFortune

All Superinterfaces:
Property
All Known Subinterfaces:
EntropyHistogram
All Known Implementing Classes:
IntervalArray, StraightRoulette

public interface WheelOfFortune
extends Property

Abstract interface for the "Wheel of Fortune" - an ordered array of frequencies used for entropy encoding.

See Also:
WheelOfFortune.java

Field Summary
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Method Summary
 int convert(long _sum)
          Converts a frequency sum to the corresponding symbol.
 long get(int _symbol)
          Returns the frequency of the given symbol.
 int getSymbols()
          Returns total number of symbols (intervals).
 long left(int _symbol)
          Returns the start of the symbol's cummulative frequency interval (the frequency sum of all preceding symbols).
 void set(int _symbol, long _freq)
          Sets a single symbol's frequency.
 void set(long[] _freq)
          Sets frequencies of all symbols at once.
 void setSymbols(int _symbols)
          Changes total number of symbols (intervals).
 long total()
          Returns the frequency sum of all symbols.
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit, get, set
 

Method Detail

setSymbols

void setSymbols(int _symbols)
Changes total number of symbols (intervals). Keeps previous frequencies (truncated or padded with the default value).

Parameters:
_symbols - New number of symbols.
See Also:
getSymbols()

getSymbols

int getSymbols()
Returns total number of symbols (intervals).

Returns:
Number of symbols.

set

void set(long[] _freq)
Sets frequencies of all symbols at once. Can be used for context re-initialization (null parameter).

Parameters:
_freq - Array of new frequencies. Can be null for context re-initialization.
See Also:
set(int,long), EntropyHistogram.decimate()

set

void set(int _symbol,
         long _freq)
Sets a single symbol's frequency.

Parameters:
_symbol - Symbol code.
_freq - New frequency of the symbol.
See Also:
set(long[]), EntropyHistogram.decimate()

total

long total()
Returns the frequency sum of all symbols. Same as left( getSymbols() ), but might be more effective.

Returns:
The total frequency sum.
See Also:
left(int), get(int), convert(long)

left

long left(int _symbol)
Returns the start of the symbol's cummulative frequency interval (the frequency sum of all preceding symbols).

Parameters:
_symbol - Symbol code.
Returns:
The sum of all preceding symbol frequencies.
See Also:
total(), get(int), convert(long)

get

long get(int _symbol)
Returns the frequency of the given symbol. Same as left( _symbol + 1 ) - left( _symbol ).

Parameters:
_symbol - Symbol code.
Returns:
The frequency of that symbol.
See Also:
total(), left(int), convert(long)

convert

int convert(long _sum)
Converts a frequency sum to the corresponding symbol.

Parameters:
_sum - Frequency sum of the unknown symbol.
Returns:
The symbol which has _sum in it's cummulative frequency interval.
See Also:
total(), left(int), get(int)