Package com.jalios.util
Class ObjectLongTreeMap
java.lang.Object
java.util.AbstractMap
java.util.TreeMap
com.jalios.util.ObjectLongTreeMap
- All Implemented Interfaces:
Serializable,Cloneable,Map,NavigableMap,SequencedMap,SortedMap
This class is a map which binds key Object to long value.
This class is NOT thread safe, synchronize read and write
operation when used in multi-threaded context if you really need features
provided by this collection.
In multithreaded context, it may be wiser to use alternative thread safe and type safe
collection such as ConcurrentHashMap<YourType, Long>.
- Author:
- Olivier Dedieu
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA Comparator that sort TreeMap of ObjectLongTreeMap by Max Valueprotected static classA Comparator that sort TreeMap of ObjectLongTreeMap by Key Valuestatic classA Comparator that sort TreeMap of ObjectLongTreeMap by Min Valuestatic classA Comparator that allow ObjectyLongTreeMap to sort multiple kind of Objectstatic classA Comparator that sort TreeMap of ObjectLongTreeMap by Key Value sorted using a sorted ListNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ComparatorSort ObjectLongTreeMap from larger to smallerlongReturns the value to which this map maps the specified key.static ComparatorSort ObjectLongTreeMap from smaller to largerstatic ComparatorgetSortedKeyComparator(String[] sort) Sort ObjectLongTreeMap ordered by a predifined Liststatic ComparatorgetSortedKeyComparator(List sort) Sort ObjectLongTreeMap ordered by a predifined Liststatic SortedSetgetSortedMapEntrySet(Map map, Comparator comparator) This method return a Sorted Set of Map.EntrylonggetSum()Returns the sum of the values of the mapvoidIncremente the value associated with the specified key.voidIncremente the value associated with the specified key.voidAssociates the specified value with the specified key in this map.Methods inherited from class java.util.TreeMap
ceilingEntry, ceilingKey, clear, clone, comparator, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, forEach, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, merge, navigableKeySet, pollFirstEntry, pollLastEntry, put, putAll, putFirst, putIfAbsent, putLast, remove, replace, replace, replaceAll, size, subMap, subMap, tailMap, tailMap, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.NavigableMap
reversedMethods inherited from interface java.util.SequencedMap
sequencedEntrySet, sequencedKeySet, sequencedValues
-
Constructor Details
-
ObjectLongTreeMap
public ObjectLongTreeMap()
-
-
Method Details
-
put
Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.- Parameters:
key- key with which the specified value is to be associated.value- value to be associated with the specified key.
-
inc
Incremente the value associated with the specified key. If this key did not exist, it is created and the value is set to '1'.- Parameters:
key- key for which the specified value must be incremented.quantity- the quantity to increment
-
inc
Incremente the value associated with the specified key. If this key did not exist, it is created and the value is set to '1'.- Parameters:
key- key for which the specified value must be incremented.
-
getLong
Returns the value to which this map maps the specified key. ReturnsdefaultValueif the map contains no mapping for this key.- Parameters:
key- key whose associated value is to be returned.defaultValue- value to return if the map contains no mapping for this key.- Returns:
- the value to which this map maps the specified key, or
defaultValueif the map contains no mapping for this key.
-
getSum
public long getSum()Returns the sum of the values of the map- Returns:
- the sum of the values of the map
- Since:
- jcms-7.0.0
-
getSortedMapEntrySet
This method return a Sorted Set of Map.Entry- Parameters:
map- a TreeMap that is an ObjectLongTreeMap or composed by ObjectLongTreeMap.comparator- the comparator to sort objects.- Returns:
- SortedSet of Map.Entry
- Since:
- jcms-7.0.0
-
getGreaterComparator
Sort ObjectLongTreeMap from larger to smaller -
getLowerComparator
Sort ObjectLongTreeMap from smaller to larger -
getSortedKeyComparator
Sort ObjectLongTreeMap ordered by a predifined List -
getSortedKeyComparator
Sort ObjectLongTreeMap ordered by a predifined List
-