Interface IdMap<Key>
-
- Type Parameters:
Key-
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
FixedIntArrayOffHeapIdMap
public interface IdMap<Key> extends Closeable
Interface for a map from Key to auto-generated contiguous integer Id's.
-
-
Field Summary
Fields Modifier and Type Field Description static intINVALID_ID
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetId(Key key)Returns the id associated with the specified key.KeygetKey(int id)Returns the key associated with the specified id.intput(Key key)Puts the specified key into the map.intsize()Returns the current size of the map, zero if the map is empty.
-
-
-
Field Detail
-
INVALID_ID
static final int INVALID_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
put
int put(Key key)
Puts the specified key into the map. The id for the key is auto-generated as follows:- If key does not exist in the map, it is inserted into the map with a new id which is equal to number of
elements in the map before the key is inserted. For example, the first key inserted will have id of 0, second
will have an id of 1, and so on.
- If key already exists in the map, then it keeps its original id.
- Parameters:
key- Key to be inserted into the map.- Returns:
- Returns the id for the key.
-
getId
int getId(Key key)
Returns the id associated with the specified key.- Returns the id of the key if it exists.
- Returns
INVALID_IDif the key does not exist in the map.- Parameters:
key- Key to get.- Returns:
- Id of the key.
-
getKey
Key getKey(int id)
Returns the key associated with the specified id.- Returns the id of the key if it exists.
- Returns null if the key does not exist in the map.
- Parameters:
id- id for which to get the key.- Returns:
- Key for the id.
-
size
int size()
Returns the current size of the map, zero if the map is empty.- Returns:
- Size of the map.
-
-