Package org.jibx.binding.util
Class ArrayMap
java.lang.Object
org.jibx.binding.util.ArrayMap
Array with reverse mapping from values to indices. This operates as the
combination of an array with ordinary int indices and a hashmap from values
back to the corresponding index position. Values are assured to be unique.
- Author:
- Dennis M. Sosnoski
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
m_array
Array of values. -
m_map
Map from values to indices.
-
-
Constructor Details
-
ArrayMap
public ArrayMap()Default constructor. -
ArrayMap
public ArrayMap(int size) Constructor with initial capacity supplied.- Parameters:
size
- initial capacity for array map
-
-
Method Details
-
get
Get value for index. The index must be within the valid range (from 0 to one less than the number of values present).- Parameters:
index
- number to be looked up- Returns:
- value at that index position
-
find
Find existing object. If the supplied value object is present in the array map its index position is returned.- Parameters:
obj
- value to be found- Returns:
- index number assigned to value, or
-1
if not found
-
findOrAdd
Add object. If the supplied value object is already present in the array map the existing index position is returned.- Parameters:
obj
- value to be added- Returns:
- index number assigned to value
-
size
public int size()Get count of values present.- Returns:
- number of values in array map
-