Class TwoWayMultiCollection

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map

    public class TwoWayMultiCollection
    extends MultiCollection
    The two-way multi-collection allows fast reverse lookup, by containing a second multi-collection, which reversely maps values to keys.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Object _add​(java.lang.Object key, java.lang.Object value)
      Internal put method, which doesn't affect the reverse collection.
      protected void _clear()
      Internal clear method, which doesn't affect the reverse collection.
      protected java.lang.Object _remove​(java.lang.Object key)
      Internal remove method, which doesn't affect the reverse collection.
      protected void _remove​(java.lang.Object key, java.lang.Object value)
      Internal remove method, which doesn't affect the reverse collection.
      java.util.Collection<java.lang.Object> add​(java.lang.Object key, java.lang.Object value)
      Associates the specified value with the specified key in this map (optional operation).
      void clear()
      Removes all mappings from this map.
      TwoWayMultiCollection getReverseMultiCollection()
      Get the reverse multi-collection.
      java.util.Collection<java.lang.Object> remove​(java.lang.Object key)
      Removes the mapping for this key from this map if it is present.
      void removeObject​(java.lang.Object key, java.lang.Object value)
      Remove a special object from the collection of a defined key.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • TwoWayMultiCollection

        public TwoWayMultiCollection()
        Create a two way map.
      • TwoWayMultiCollection

        protected TwoWayMultiCollection​(TwoWayMultiCollection reverse)
        internal constrcutor for connecting two two-way multi-collection.
    • Method Detail

      • getReverseMultiCollection

        public TwoWayMultiCollection getReverseMultiCollection()
        Get the reverse multi-collection.
        Returns:
        The reverse multi-collection.
      • add

        public java.util.Collection<java.lang.Object> add​(java.lang.Object key,
                                                          java.lang.Object value)
        Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for this key, the old value is replaced by the specified value. (A map m.containsKey(k) would return
        Overrides:
        add in class MultiCollection
        Parameters:
        key - key with which the specified value is to be associated.
        value - value to be associated with the specified key.
        Returns:
        The collection associated to the key.
        Throws:
        java.lang.UnsupportedOperationException - if the
        java.lang.ClassCastException - if the class of the specified key or value prevents it from being stored in this map.
        java.lang.IllegalArgumentException - if some aspect of this key or value prevents it from being stored in this map.
        java.lang.NullPointerException - this map does not permit
      • _add

        protected java.lang.Object _add​(java.lang.Object key,
                                        java.lang.Object value)
        Internal put method, which doesn't affect the reverse collection.
      • clear

        public void clear()
        Removes all mappings from this map.
        Specified by:
        clear in interface java.util.Map
        Overrides:
        clear in class MultiCollection
      • _clear

        protected void _clear()
        Internal clear method, which doesn't affect the reverse collection.
      • remove

        public java.util.Collection<java.lang.Object> remove​(java.lang.Object key)
        Removes the mapping for this key from this map if it is present. More formally, if this map contains a mapping from key (key==null ? k==null : key.equals(k)), that mapping is removed. (The map can contain at most one such mapping.)
        Specified by:
        remove in interface java.util.Map
        Overrides:
        remove in class MultiCollection
        Parameters:
        key - key whose mapping is to be removed from the map.
        Returns:
        collection associated with specified key, or
        Throws:
        java.lang.ClassCastException - if the key is of an inappropriate type for this map (optional).
        java.lang.NullPointerException - if the key is
      • _remove

        protected java.lang.Object _remove​(java.lang.Object key)
        Internal remove method, which doesn't affect the reverse collection.
      • removeObject

        public void removeObject​(java.lang.Object key,
                                 java.lang.Object value)
        Remove a special object from the collection of a defined key.
        Overrides:
        removeObject in class MultiCollection
      • _remove

        protected void _remove​(java.lang.Object key,
                               java.lang.Object value)
        Internal remove method, which doesn't affect the reverse collection.