Class MapWithOrdinalImpl<K,V>

Type Parameters:
K - key type
V - value type
All Implemented Interfaces:

public class MapWithOrdinalImpl<K,V> extends Object implements MapWithOrdinal<K,V>
An implementation of 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 getOrdinal(Object) before attempting to execute a lookup with an ordinal.

  • Constructor Details

    • MapWithOrdinalImpl

      public MapWithOrdinalImpl()
  • Method Details