Class TreeManyToManyMap<K,V>

java.lang.Object
com.github.tadukoo.util.map.ManyToManyMap<K,V>
com.github.tadukoo.util.map.TreeManyToManyMap<K,V>

public class TreeManyToManyMap<K,V> extends ManyToManyMap<K,V>
A ManyToManyMap class that uses TreeMultiMap as the backing MultiMap class.
Since:
Alpha v.0.1
Version:
Alpha v.0.2
Author:
Logan Ferree (Tadukoo)
  • Constructor Details

    • TreeManyToManyMap

      public TreeManyToManyMap()
      Creates a new HashManyToManyMap where the backing TreeManyToManyMap uses the natural ordering of its keys.
    • TreeManyToManyMap

      public TreeManyToManyMap(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator)
      Creates a new TreeManyToManyMap where the backing TreeMultiMap uses the given Comparators to determine the ordering of its keys and values.
      Parameters:
      keyComparator - The Comparator to use in ordering the keys
      valueComparator - The Comparator to use in ordering the values
    • TreeManyToManyMap

      @SafeVarargs public TreeManyToManyMap(Pair<K,V>... entries)
      Creates a new TreeManyToManyMap where the given Pairs are loaded into the map right away.
      Parameters:
      entries - A collection of key-value Pairs to be put in this ManyToManyMap
    • TreeManyToManyMap

      public TreeManyToManyMap(Map<K,V> map)
      Creates a new TreeManyToManyMap where the backing TreeMultiMap is constructed with the same mappings as the specified Map. The backing TreeMultiMap uses the natural ordering of its keys.
      Parameters:
      map - The Map whose mappings are to be placed in the backing TreeMultiMap
    • TreeManyToManyMap

      public TreeManyToManyMap(SortedMap<K,V> map)
      Creates a new TreeManyToManyMap where the backing TreeMultiMap is constructed with the same mappings as the specified SortedMap. The backing TreeMultiMap also uses the Comparator used by the given SortedMap.
      Parameters:
      map - The SortedMap whose mappings are to be placed in the backing TreeMultiMap
    • TreeManyToManyMap

      public TreeManyToManyMap(MultiMap<K,V> multiMap)
      Creates a new TreeManyToManyMap where the backing TreeMultiMap uses the given Comparator to determine the ordering of its keys.
      The MultiMap is then populated with the values present in the specified MultiMap.
      Parameters:
      multiMap - The MultiMap whose mappings are to be placed in this MultiMap
    • TreeManyToManyMap

      public TreeManyToManyMap(ManyToManyMap<K,V> manyToManyMap)
      Creates a new TreeManyToManyMap where the backing TreeMultiMap uses the natural ordering of its keys.
      The ManyToManyMap is then populated with the values present in the specified ManyToManyMap.
      Parameters:
      manyToManyMap - The ManyToManyMap whose mappings are to be placed in this ManyToManyMap
  • Method Details

    • equals

      public boolean equals(Object o)
      Compares the given object with this TreeManyToManyMap for equality. Returns true if the given object is also a TreeManyToManyMap and the two TreeManyToManyMaps represent the same mappings. If they're both TreeManyToManyMaps, it will run ManyToManyMap.equals(java.lang.Object) to compare them.
      Overrides:
      equals in class ManyToManyMap<K,V>
      Parameters:
      o - The object to be compared for equality with this TreeManyToManyMap
      Returns:
      true if the given object is equivalent to this TreeManyToManyMap
    • keyComparator

      public Comparator<? super K> keyComparator()
      Returns:
      The keys Comparator used by the keysToValues TreeMultiMap
    • valueComparator

      public Comparator<? super V> valueComparator()
      Returns:
      The values Comparator used by the valuesToKeys TreeMultiMap
    • asKeysToValuesMultiMap

      public TreeMultiMap<K,V> asKeysToValuesMultiMap()
      Returns the underlying TreeMultiMap used for keys to values.
      Returns:
      The underlying TreeMultiMap of keys to values
    • asValuesToKeysMultiMap

      public TreeMultiMap<V,K> asValuesToKeysMultiMap()
      Returns the underlying TreeMultiMap used for values to keys.
      Returns:
      The underlying TreeMultiMap of values to keys
    • firstKey

      public K firstKey()
      Returns:
      The first (lowest) key in this manyToManyMap
    • lastKey

      public K lastKey()
      Returns:
      The last (highest) key in this manyToManyMap
    • firstEntry

      public Map.Entry<K,List<V>> firstEntry()
      Returns:
      A key-value mapping associated with the least key in this manyToManyMap, or null if the manyToManyMap is empty
    • lastEntry

      public Map.Entry<K,List<V>> lastEntry()
      Returns:
      A key-value mapping associated with the greatest key in this map, or null if the manyToManyMap is empty
    • pollFirstEntry

      public Map.Entry<K,List<V>> pollFirstEntry()
      Removes and returns a key-value mapping associated with the least key in this manyToManyMap, or null if the manyToManyMap is empty.
      Returns:
      The removed first entry of this manyToManyMap, or null if it's empty
    • pollLastEntry

      public Map.Entry<K,List<V>> pollLastEntry()
      Removes and returns a key-value mapping associated with the greatest key in this manyToManyMap, or null if the manyToManyMap is empty.
      Returns:
      The removed last entry of this manyToManyMap, or null if it's empty
    • lowerKey

      public K lowerKey(K key)
      Returns the greatest key strictly less than the given key, or null if there is no such key.
      Parameters:
      key - The key
      Returns:
      The greatest key less than key, or null if there is no such key
    • higherKey

      public K higherKey(K key)
      Returns the least key strictly greater than the given key, or null if there is no such key.
      Parameters:
      key - The key
      Returns:
      The least key greater than key, or null if there is no such key
    • lowerEntry

      public Map.Entry<K,List<V>> lowerEntry(K key)
      Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.
      Parameters:
      key - The key
      Returns:
      An entry with the greatest key less than key, or null if there is no such key
    • higherEntry

      public Map.Entry<K,List<V>> higherEntry(K key)
      Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.
      Parameters:
      key - The key
      Returns:
      An entry with the least key greater than key, or null if there is no such key
    • floorKey

      public K floorKey(K key)
      Returns the greatest key less than or equal to the given key, or null if there is no such key.
      Parameters:
      key - The key
      Returns:
      The greatest key less than or equal to key, or null if there is no such key
    • ceilingKey

      public K ceilingKey(K key)
      Returns the least key greater than or equal to the given key, or null if there is no such key.
      Parameters:
      key - The key
      Returns:
      The least key greater than or equal to key, or null if there is no such key
    • floorEntry

      public Map.Entry<K,List<V>> floorEntry(K key)
      Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
      Parameters:
      key - The key
      Returns:
      An entry with the greatest key less than or equal to key, or null if there is no such key
    • ceilingEntry

      public Map.Entry<K,List<V>> ceilingEntry(K key)
      Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.
      Parameters:
      key - The key
      Returns:
      An entry with the least key greater than or equal to key, or null if there is no such key
    • descendingKeySet

      public NavigableSet<K> descendingKeySet()
      Returns:
      A reverse order navigable set view of the keys in this manyToManyMap
      See Also:
    • descendingMap

      public NavigableMap<K,List<V>> descendingMap()
      Returns:
      R reverse order view of this manyToManyMap
      See Also:
    • subMap

      public SortedMap<K,List<V>> subMap(K fromKey, K toKey)
      Parameters:
      fromKey - low end point (inclusive) of the keys in the returned map
      toKey - high end point (exclusive) of the keys in the returned map
      Returns:
      A view of the portion of this manyToManyMap whose keys range from fromKey, inclusive, to toKey, exclusive
      See Also:
    • subMap

      public NavigableMap<K,List<V>> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
      Parameters:
      fromKey - low end point of the keys in the returned map
      fromInclusive - true if the low end point is to be included in the returned view
      toKey - high end point of the keys in the returned map
      toInclusive - true if the high end point is to be included in the returned view
      Returns:
      A view of the portion of this map whose keys range from fromKey to toKey
      See Also:
    • headMap

      public SortedMap<K,List<V>> headMap(K toKey)
      Parameters:
      toKey - high end point (exclusive) of the keys in the returned map
      Returns:
      A view of the portion of this manyToManyMap whose keys are strictly less than toKey
      See Also:
    • headMap

      public NavigableMap<K,List<V>> headMap(K toKey, boolean inclusive)
      Parameters:
      toKey - high end point of the keys in the returned map
      inclusive - true if the high end point is to be included in the returned view
      Returns:
      A view of the portion of this manyToManyMap whose keys are less than (or equal to, if inclusive is true) toKey
      See Also:
    • tailMap

      public SortedMap<K,List<V>> tailMap(K fromKey)
      Parameters:
      fromKey - low end point (inclusive) of the keys in the returned map
      Returns:
      A view of the portion of this manyToManyMap whose keys are greater than or equal to fromKey
      See Also:
    • tailMap

      public NavigableMap<K,List<V>> tailMap(K fromKey, boolean inclusive)
      Parameters:
      fromKey - low end point of the keys in the returned map
      inclusive - true if the low end point is to be included in the returned view
      Returns:
      A view of the portion of this manyToManyMap whose keys are greater than (or equal to, if inclusive is true) fromKey
      See Also: