Interface MapWithOrdinal<K,V>

Type Parameters:
K - key type
V - 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 Details

    • getByOrdinal

      V getByOrdinal(int id)
    • getOrdinal

      int getOrdinal(K key)
    • size

      int size()
    • isEmpty

      boolean isEmpty()
    • get

      V get(K key)
    • getAll

      Collection<V> getAll(K key)
    • put

      boolean put(K key, V value, boolean overwrite)
    • values

      Collection<V> values()
    • containsKey

      boolean containsKey(K key)
    • remove

      boolean remove(K key, V value)
    • removeAll

      boolean removeAll(K key)
    • clear

      void clear()
    • keys

      Set<K> keys()