Package org.jibx.binding.util
Class ArrayMap
- java.lang.Object
-
- org.jibx.binding.util.ArrayMap
-
public class ArrayMap extends java.lang.Object
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
find(java.lang.Object obj)
Find existing object.int
findOrAdd(java.lang.Object obj)
Add object.java.lang.Object
get(int index)
Get value for index.int
size()
Get count of values present.
-
-
-
Method Detail
-
get
public java.lang.Object get(int index)
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
public int find(java.lang.Object obj)
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
public int findOrAdd(java.lang.Object obj)
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
-
-