Class MultiBinaryLongMap.PrimaryBinaryLongMap

    • Constructor Detail

      • PrimaryBinaryLongMap

        public PrimaryBinaryLongMap()
        Construct a PrimaryBinaryLongMap.
    • Method Detail

      • inflateRep

        protected void inflateRep()
        Inflate the underlying representation of the PrimaryBinaryLongMap to use the LongStorage to support multiple delegating BinaryLongMap instances.

        Note: it is the caller's responsibility to hold the master exclusive lock during this operation

      • deflateRep

        protected void deflateRep()
        Deflate the underlying representation of the PrimaryBinaryLongMap to use the main key-tree to associate a single long value with each key (logically represented by this PrimaryBinaryLongMap).

        Note: it is the caller's responsibility to hold the master exclusive lock during this operation

      • addListener

        public void addListener​(MultiBinaryLongMap.BinaryLongMapListener listener)
        Add the specified listener to the collection of listeners that this DelegatingPrimaryBinaryLongMap dispatches notifications to.
        Parameters:
        listener - the listener to add to the collection of listeners that this DelegatingPrimaryBinaryLongMap dispatches notifications to
      • removeListener

        public void removeListener​(MultiBinaryLongMap.BinaryLongMapListener listener)
        Remove the specified listener from the collection of listeners that this DelegatingPrimaryBinaryLongMap dispatches notifications to.
        Parameters:
        listener - the listener to remove from the collection of listeners that this DelegatingPrimaryBinaryLongMap dispatches notifications to
      • get

        public long get​(Binary binKey)
        Find the specified key in the map and return the value associated with it.
        Specified by:
        get in interface BinaryLongMap
        Overrides:
        get in class MultiBinaryLongMap.WrapperBinaryLongMap
        Parameters:
        binKey - a Binary key
        Returns:
        the value associated with the specified key, or 0L if the specified key is not in the map
      • put

        public void put​(Binary binKey,
                        long lValue)
        Blindly store the passed value for the specified key, adding the key if it is not already in the map, or replacing the current value if the key is in the map.

        Note that associating the value zero with a key is analogous to removing the key.

        Specified by:
        put in interface BinaryLongMap
        Overrides:
        put in class MultiBinaryLongMap.WrapperBinaryLongMap
        Parameters:
        binKey - the Binary key to add or update
        lValue - the value to associate with the key
      • putIfAbsent

        public boolean putIfAbsent​(Binary binKey,
                                   long lValue)
        Store the passed value for the specified key, only if the key does not currently exist in the map.

        Note that associating the value zero with a key using this method will have no effect, since were that key already present, there would be no change, and were it not present, the value zero is analogous to removing the key, which again is no change (since it is not present).

        Specified by:
        putIfAbsent in interface BinaryLongMap
        Overrides:
        putIfAbsent in class MultiBinaryLongMap.WrapperBinaryLongMap
        Parameters:
        binKey - a Binary key
        lValue - the new value to associate with the passed key
        Returns:
        true iff the key was not present in the map, and now it is present in the map associated with the passed value
      • replace

        public boolean replace​(Binary binKey,
                               long lValueOld,
                               long lValueNew)
        Store the passed "new" value for the specified key, only if the current value associated with the specified key is the same as the specified "old" value.

        Note that replacing the value of zero is analogous to putIfAbsent, and associating the value zero with a key using this method is the same as remove passing the old value to match.

        Specified by:
        replace in interface BinaryLongMap
        Overrides:
        replace in class MultiBinaryLongMap.WrapperBinaryLongMap
        Parameters:
        binKey - a Binary key
        lValueOld - the assumed old value to replace
        lValueNew - the new value to associate with the passed key
        Returns:
        true iff the key was associated with the passed "old" value, and now it is associated with the passed "new" value
      • remove

        public boolean remove​(Binary binKey,
                              long lValue)
        Remove the specified Binary key from the map iff it exists in the map and is associated with the specified value.

        Note that removing an association whose value is zero has no effect.

        Specified by:
        remove in interface BinaryLongMap
        Overrides:
        remove in class MultiBinaryLongMap.WrapperBinaryLongMap
        Parameters:
        binKey - a Binary key
        lValue - the value that the key must have in order to be removed
        Returns:
        true iff the map contained the key, it was associated with the specified value, and has now been removed
      • keyAdded

        public void keyAdded​(Binary binKey)
        A notification that the primary map has added a new Binary/long key/value mapping; this implicitly creates a new key/value mapping in each delegating map, with the value being 0L.
        Specified by:
        keyAdded in interface MultiBinaryLongMap.BinaryLongMapListener
        Parameters:
        binKey - the key that was added
      • keyRemoving

        public void keyRemoving​(Binary binKey)
        A notification that the primary map is removing a Binary/long key/value mapping; this implies that the existing key/value mapping for the same Binary key in each delegating map is also being removed.
        Specified by:
        keyRemoving in interface MultiBinaryLongMap.BinaryLongMapListener
        Parameters:
        binKey - the key that is being removed
      • mapClearing

        public void mapClearing()
        A notification that the primary map is about to be cleared; this implies that all of the existing key/value mappings in each delegating map are about to be removed, but that no per-mapping events will be generated in response to those removals.
        Specified by:
        mapClearing in interface MultiBinaryLongMap.BinaryLongMapListener
      • mapCleared

        public void mapCleared()
        A notification that the primary map has been cleared; this implies that all of the existing key/value mappings in each delegating map have also been removed.
        Specified by:
        mapCleared in interface MultiBinaryLongMap.BinaryLongMapListener