Class MultiMap

  • All Implemented Interfaces:
    Serializable, Cloneable, Map

    public class MultiMap
    extends HashMap
    An implementation of a MultiMap, which is basically a Map with multiple values for a key. This will be removed when SUN see sense and include it in the JDK java.util package as standard.
    See Also:
    Serialized Form
    • Constructor Detail

      • MultiMap

        public MultiMap()
        Constructor.
      • MultiMap

        public MultiMap​(int initialCapacity)
        Constructor.
        Parameters:
        initialCapacity - the initial capacity
      • MultiMap

        public MultiMap​(int initialCapacity,
                        float loadFactor)
        Constructor.
        Parameters:
        initialCapacity - initial capacity
        loadFactor - load factor for the Map.
      • MultiMap

        public MultiMap​(MultiMap map)
        Constructor.
        Parameters:
        map - The initial Map.
    • Method Detail

      • containsValue

        public boolean containsValue​(Object value)
        Check if the map contains the passed value.
        Specified by:
        containsValue in interface Map
        Overrides:
        containsValue in class HashMap
        Parameters:
        value - the value to search for
        Returns:
        true if the list contains the value
      • put

        public Object put​(Object key,
                          Object value)
        Add a key, and its value, to the map.
        Specified by:
        put in interface Map
        Overrides:
        put in class HashMap
        Parameters:
        key - the key to set
        value - the value to set the key to
        Returns:
        the value added when successful, or null if an error
      • removeKeyValue

        public Object removeKeyValue​(Object key,
                                     Object item)
        Removes a specific key,value pairing from map. The item is removed from the collection mapped to the specified key.
        Parameters:
        key - the key to remove from
        item - the value to remove
        Returns:
        the value removed (which was passed in)
      • clear

        public void clear()
        Clear the map.
        Specified by:
        clear in interface Map
        Overrides:
        clear in class HashMap
      • values

        public Collection values()
        Accessor for the values in the Map.
        Specified by:
        values in interface Map
        Overrides:
        values in class HashMap
        Returns:
        all of the values in the map
      • clone

        public Object clone()
        Method to clone the Map. Performs a shallow copy of the entry set.
        Overrides:
        clone in class HashMap
        Returns:
        the cloned map
      • createCollection

        protected Collection createCollection​(Collection c)
        Creates a new instance of the map value Collection container.
        Parameters:
        c - the collection to copy
        Returns:
        new collection