- Type Parameters:
K
- key typeV
- value type
- All Known Implementing Classes:
MapWithOrdinalImpl
,MultiMapWithOrdinal
,PromotableMultiMapWithOrdinal
public interface MapWithOrdinal<K,V>
An implementation of a map that supports constant time look-up by a generic key or an ordinal.
This class extends the functionality a regular Map
with ordinal lookup support. Upon
insertion an unused ordinal is assigned to the inserted (key, value) tuple. Upon update the same
ordinal id is re-used while value is replaced. Upon deletion of an existing item, its
corresponding ordinal is recycled and could be used by another item.
For any instance with N items, this implementation guarantees that ordinals are in the range
of [0, N). However, the ordinal assignment is dynamic and may change after an insertion or
deletion. Consumers of this class are responsible for explicitly checking the ordinal
corresponding to a key via MultiMapWithOrdinal.getOrdinal(Object)
before attempting to
execute a lookup with an ordinal.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(K key) getByOrdinal
(int id) int
getOrdinal
(K key) boolean
isEmpty()
keys()
boolean
boolean
boolean
int
size()
values()
-
Method Details
-
getByOrdinal
-
getOrdinal
-
size
int size() -
isEmpty
boolean isEmpty() -
get
-
getAll
-
put
-
values
Collection<V> values() -
containsKey
-
remove
-
removeAll
-
clear
void clear() -
keys
-