Class KeyValueArrayMap

  • All Implemented Interfaces:
    Map

    public class KeyValueArrayMap
    extends AbstractKeyBasedMap
    KeyValueArrayMap is a Map implementation backed by an array of keys, and an array of the associated values.

    This implementation:

    • does not support updates or removals
    • does not ensure the uniqueness of keys (this is the caller's responsibility)
    • is not thread-safe

    Since:
    Coherence 12.1.2
    Author:
    rhl 2011.12.20
    • Field Detail

      • m_aoKey

        protected Object[] m_aoKey
        The array containing map keys.
      • m_aoValue

        protected Object[] m_aoValue
        The array containing map values.
      • m_iKey

        protected int m_iKey
        The index into the key array of the first key.
      • m_iValue

        protected int m_iValue
        The index into the value array of the first value.
      • m_cSize

        protected int m_cSize
        The number of map entries.
    • Constructor Detail

      • KeyValueArrayMap

        public KeyValueArrayMap​(Object[] aoKey,
                                Object[] aoValue)
        Construct a KeyValueArrayMap backed by the specified key and value arrays. The specified arrays must be non-null and of equal length.
        Parameters:
        aoKey - the array of keys
        aoValue - the array of values
      • KeyValueArrayMap

        public KeyValueArrayMap​(Object[] aoKey,
                                int iKey,
                                Object[] aoValue,
                                int iValue,
                                int cSize)
        Construct a KeyValueArrayMap backed by ranges of the specified key and value arrays.
        Parameters:
        aoKey - the array of keys
        iKey - the index of the first key
        aoValue - the array of values
        iValue - the index of the first value
        cSize - the number of entries
    • Method Detail

      • get

        public Object get​(Object oKey)
        Returns the value to which this map maps the specified key.
        Specified by:
        get in interface Map
        Specified by:
        get in class AbstractKeyBasedMap
        Parameters:
        oKey - the key object
        Returns:
        the value to which this map maps the specified key, or null if the map contains no mapping for this key
      • iterateKeys

        protected Iterator iterateKeys()
        Create an iterator over the keys in this Map. The Iterator must support remove() if the Map supports removal.
        Specified by:
        iterateKeys in class AbstractKeyBasedMap
        Returns:
        a new instance of an Iterator over the keys in this Map
      • size

        public int size()
        Returns the number of key-value mappings in this map.
        Specified by:
        size in interface Map
        Overrides:
        size in class AbstractKeyBasedMap
        Returns:
        the number of key-value mappings in this map