Package org.jibx.util
Class StringSizedSet
- java.lang.Object
-
- org.jibx.util.StringSizedSet
-
public class StringSizedSet extends Object
Fixed size hash set ofStringvalues.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_FILL_FRACTIONDefault fill fraction for sizing of tables.protected intm_arraySizeSize of array used for keys.protected intm_hitOffsetOffset added (modulo table size) to slot number on collision.protected String[]m_keyTableArray of key table slots.
-
Constructor Summary
Constructors Constructor Description StringSizedSet(int count)Constructor with only value count specified.StringSizedSet(int count, double fill)Constructor with full specification.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(String key)Add a key to the set.voidclear()Set the table to the empty state.booleancontains(String key)Check if an entry is present in the table.
-
-
-
Field Detail
-
DEFAULT_FILL_FRACTION
public static final double DEFAULT_FILL_FRACTION
Default fill fraction for sizing of tables.- See Also:
- Constant Field Values
-
m_arraySize
protected final int m_arraySize
Size of array used for keys.
-
m_keyTable
protected final String[] m_keyTable
Array of key table slots.
-
m_hitOffset
protected final int m_hitOffset
Offset added (modulo table size) to slot number on collision.
-
-
Constructor Detail
-
StringSizedSet
public StringSizedSet(int count, double fill)Constructor with full specification.- Parameters:
count- number of values to assume in sizing of tablefill- fraction fill for table (maximum of0.7, to prevent excessive collisions)
-
StringSizedSet
public StringSizedSet(int count)
Constructor with only value count specified. Uses default fill fraction and miss value.- Parameters:
count- number of values to assume in initial sizing of table
-
-
Method Detail
-
add
public boolean add(String key)
Add a key to the set. If the key is already present in the set, this does nothing.- Parameters:
key- key to be added to table (non-null)- Returns:
trueif added,falseif already present value if key not previously present in table
-
contains
public final boolean contains(String key)
Check if an entry is present in the table.- Parameters:
key- key to be found- Returns:
trueif key found in table,falseif not
-
clear
public void clear()
Set the table to the empty state.
-
-