Package com.jalios.util
Class ObjectLongTreeMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.TreeMap
-
- com.jalios.util.ObjectLongTreeMap
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map
,java.util.NavigableMap
,java.util.SortedMap
public class ObjectLongTreeMap extends java.util.TreeMap
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 asConcurrentHashMap<YourType, Long>
.- Author:
- Olivier Dedieu
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ObjectLongTreeMap.GreaterComparator
A Comparator that sort TreeMap of ObjectLongTreeMap by Max Valueprotected static class
ObjectLongTreeMap.KeyComparator
A Comparator that sort TreeMap of ObjectLongTreeMap by Key Valuestatic class
ObjectLongTreeMap.LowerComparator
A Comparator that sort TreeMap of ObjectLongTreeMap by Min Valuestatic class
ObjectLongTreeMap.ObjectComparator
A Comparator that allow ObjectyLongTreeMap to sort multiple kind of Objectstatic class
ObjectLongTreeMap.SortedKeyComparator
A Comparator that sort TreeMap of ObjectLongTreeMap by Key Value sorted using a sorted List
-
Constructor Summary
Constructors Constructor Description ObjectLongTreeMap()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Comparator
getGreaterComparator()
Sort ObjectLongTreeMap from larger to smallerlong
getLong(java.lang.Object key, long defaultValue)
Returns the value to which this map maps the specified key.static java.util.Comparator
getLowerComparator()
Sort ObjectLongTreeMap from smaller to largerstatic java.util.Comparator
getSortedKeyComparator(java.lang.String[] sort)
Sort ObjectLongTreeMap ordered by a predifined Liststatic java.util.Comparator
getSortedKeyComparator(java.util.List sort)
Sort ObjectLongTreeMap ordered by a predifined Liststatic java.util.SortedSet
getSortedMapEntrySet(java.util.Map map, java.util.Comparator comparator)
This method return a Sorted Set of Map.Entrylong
getSum()
Returns the sum of the values of the mapvoid
inc(java.lang.Object key)
Incremente the value associated with the specified key.void
inc(java.lang.Object key, long quantity)
Incremente the value associated with the specified key.void
put(java.lang.Object key, long value)
Associates the specified value with the specified key in this map.-
Methods inherited from class java.util.TreeMap
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, forEach, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, put, putAll, remove, replace, replace, replaceAll, size, subMap, subMap, tailMap, tailMap, values
-
-
-
-
Method Detail
-
put
public void put(java.lang.Object key, long value)
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
public void inc(java.lang.Object key, long quantity)
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
public void inc(java.lang.Object key)
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
public long getLong(java.lang.Object key, long defaultValue)
Returns the value to which this map maps the specified key. ReturnsdefaultValue
if 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
defaultValue
if 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
public static java.util.SortedSet getSortedMapEntrySet(java.util.Map map, java.util.Comparator comparator)
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
public static java.util.Comparator getGreaterComparator()
Sort ObjectLongTreeMap from larger to smaller
-
getLowerComparator
public static java.util.Comparator getLowerComparator()
Sort ObjectLongTreeMap from smaller to larger
-
getSortedKeyComparator
public static java.util.Comparator getSortedKeyComparator(java.util.List sort)
Sort ObjectLongTreeMap ordered by a predifined List
-
getSortedKeyComparator
public static java.util.Comparator getSortedKeyComparator(java.lang.String[] sort)
Sort ObjectLongTreeMap ordered by a predifined List
-
-