Class TreeSortedMap<K,​V>

    • Field Detail

      • treeMap

        private java.util.TreeMap<K,​V> treeMap
    • Constructor Detail

      • TreeSortedMap

        public TreeSortedMap()
      • TreeSortedMap

        public TreeSortedMap​(java.util.Comparator<? super K> comparator)
      • TreeSortedMap

        public TreeSortedMap​(java.util.Map<? extends K,​? extends V> map)
      • TreeSortedMap

        public TreeSortedMap​(java.util.Comparator<? super K> comparator,
                             java.util.Map<? extends K,​? extends V> map)
      • TreeSortedMap

        public TreeSortedMap​(java.util.SortedMap<K,​? extends V> map)
      • TreeSortedMap

        public TreeSortedMap​(Pair<K,​V>... pairs)
    • Method Detail

      • newMap

        public static <K,​V> TreeSortedMap<K,​V> newMap()
      • newMap

        public static <K,​V> TreeSortedMap<K,​V> newMap​(java.util.Comparator<? super K> comparator)
      • newMap

        public static <K,​V> TreeSortedMap<K,​V> newMap​(java.util.Map<? extends K,​? extends V> map)
      • newMap

        public static <K,​V> TreeSortedMap<K,​V> newMap​(java.util.Comparator<? super K> comparator,
                                                                  java.util.Map<? extends K,​? extends V> map)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(Pair<K,​V>... pairs)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(java.util.Comparator<? super K> comparator,
                                                                      Pair<K,​V>... pairs)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(K key,
                                                                      V value)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(K key1,
                                                                      V value1,
                                                                      K key2,
                                                                      V value2)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(K key1,
                                                                      V value1,
                                                                      K key2,
                                                                      V value2,
                                                                      K key3,
                                                                      V value3)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(K key1,
                                                                      V value1,
                                                                      K key2,
                                                                      V value2,
                                                                      K key3,
                                                                      V value3,
                                                                      K key4,
                                                                      V value4)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(java.util.Comparator<? super K> comparator,
                                                                      K key,
                                                                      V value)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(java.util.Comparator<? super K> comparator,
                                                                      K key1,
                                                                      V value1,
                                                                      K key2,
                                                                      V value2)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(java.util.Comparator<? super K> comparator,
                                                                      K key1,
                                                                      V value1,
                                                                      K key2,
                                                                      V value2,
                                                                      K key3,
                                                                      V value3)
      • newMapWith

        public static <K,​V> TreeSortedMap<K,​V> newMapWith​(java.util.Comparator<? super K> comparator,
                                                                      K key1,
                                                                      V value1,
                                                                      K key2,
                                                                      V value2,
                                                                      K key3,
                                                                      V value3,
                                                                      K key4,
                                                                      V value4)
      • with

        public TreeSortedMap<K,​V> with​(K key1,
                                             V value1,
                                             K key2,
                                             V value2,
                                             K key3,
                                             V value3)
      • with

        public TreeSortedMap<K,​V> with​(K key1,
                                             V value1,
                                             K key2,
                                             V value2,
                                             K key3,
                                             V value3,
                                             K key4,
                                             V value4)
      • size

        public int size()
        Description copied from interface: RichIterable
        Returns the number of items in this iterable.
        Specified by:
        size in interface java.util.Map<K,​V>
        Specified by:
        size in interface RichIterable<K>
      • removeKey

        public V removeKey​(K key)
        Description copied from interface: MutableMapIterable
        Remove an entry from the map at the specified key.
        Specified by:
        removeKey in interface MutableMapIterable<K,​V>
        Returns:
        The value removed from entry at key, or null if not found.
        See Also:
        Map.remove(Object)
      • equals

        public boolean equals​(java.lang.Object o)
        Description copied from interface: MapIterable
        Follows the same general contract as Map.equals(Object).
        Specified by:
        equals in interface java.util.Map<K,​V>
        Specified by:
        equals in interface MapIterable<K,​V>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Description copied from interface: MapIterable
        Follows the same general contract as Map.hashCode().
        Specified by:
        hashCode in interface java.util.Map<K,​V>
        Specified by:
        hashCode in interface MapIterable<K,​V>
        Overrides:
        hashCode in class java.lang.Object
      • forEachKeyValue

        public void forEachKeyValue​(Procedure2<? super K,​? super V> procedure2)
        Description copied from interface: MapIterable
        Calls the procedure with each key-value pair of the map.
             final Collection<String> collection = new ArrayList<String>();
             MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three");
             map.forEachKeyValue((Integer key, String value) -> collection.add(String.valueOf(key) + value));
             Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
         
        Specified by:
        forEachKeyValue in interface MapIterable<K,​V>
      • firstKey

        public K firstKey()
        Specified by:
        firstKey in interface java.util.SortedMap<K,​V>
      • lastKey

        public K lastKey()
        Specified by:
        lastKey in interface java.util.SortedMap<K,​V>
      • entrySet

        public MutableSet<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in interface MutableSortedMap<K,​V>
        Specified by:
        entrySet in interface java.util.SortedMap<K,​V>
      • keySet

        public MutableSet<K> keySet()
        Description copied from interface: MutableSortedMap
        The underlying set for the keys is sorted in ascending order according to their natural ordering or a custom comparator. However, Java 5 TreeMap returns a keySet that does not inherit from SortedSet therefore we have decided to return the keySet simply as a MutableSet to maintain Java 5 compatibility.
        Specified by:
        keySet in interface java.util.Map<K,​V>
        Specified by:
        keySet in interface MutableSortedMap<K,​V>
        Specified by:
        keySet in interface java.util.SortedMap<K,​V>
      • values

        public MutableCollection<V> values()
        Specified by:
        values in interface java.util.Map<K,​V>
        Specified by:
        values in interface MutableSortedMap<K,​V>
        Specified by:
        values in interface java.util.SortedMap<K,​V>
      • comparator

        public java.util.Comparator<? super K> comparator()
        Specified by:
        comparator in interface java.util.SortedMap<K,​V>
        Specified by:
        comparator in interface SortedMapIterable<K,​V>
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
        Specified by:
        get in interface MapIterable<K,​V>
        See Also:
        Map.get(Object)
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
      • putAll

        public void putAll​(java.util.Map<? extends K,​? extends V> map)
        Specified by:
        putAll in interface java.util.Map<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
        Specified by:
        containsKey in interface MapIterable<K,​V>
        See Also:
        Map.containsKey(Object)
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
        Specified by:
        containsValue in interface MapIterable<K,​V>
        See Also:
        Map.containsValue(Object)
      • toString

        public java.lang.String toString()
        Description copied from class: AbstractRichIterable
        Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.
         Assert.assertEquals("[]", Lists.mutable.empty().toString());
         Assert.assertEquals("[1]", Lists.mutable.with(1).toString());
         Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());
         
        Specified by:
        toString in interface MapIterable<K,​V>
        Specified by:
        toString in interface RichIterable<K>
        Overrides:
        toString in class AbstractRichIterable<V>
        Returns:
        a string representation of this collection.
        See Also:
        AbstractCollection.toString()
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException