Package com.cobber.fta
Class FiniteMap
- Object
-
- FiniteMap
-
- All Implemented Interfaces:
Map<String,Long>
public class FiniteMap extends Object implements Map<String,Long>
A Map of Strings to Longs with a finite capacity. Note: This maximum capacity should be set before any elements are added to the Map.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<String,Long>>
entrySet()
boolean
equals(Object o)
Long
get(Object key)
Map<String,Long>
getImpl()
int
getMaxCapacity()
boolean
isEmpty()
boolean
isSorted()
Set<String>
keySet()
boolean
mergeIfSpace(String key, Long value, java.util.function.BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
Similar toMap.merge(K, V, java.util.function.BiFunction<? super V, ? super V, ? extends V>)
but if this FiniteMap is full and this is a new key then just return false.Long
put(String key, Long value)
void
putAll(Map<? extends String,? extends Long> m)
Long
remove(Object key)
void
setMaxCapacity(int maxCapacity)
int
size()
void
sortByKey(NavigableMap<String,Long> newMap)
void
sortByValue()
Collection<Long>
values()
-
-
-
Method Detail
-
getMaxCapacity
public int getMaxCapacity()
-
setMaxCapacity
public void setMaxCapacity(int maxCapacity)
-
sortByValue
public void sortByValue()
-
sortByKey
public void sortByKey(NavigableMap<String,Long> newMap)
-
getImpl
public Map<String,Long> getImpl()
-
isSorted
public boolean isSorted()
-
mergeIfSpace
public boolean mergeIfSpace(String key, Long value, java.util.function.BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
Similar toMap.merge(K, V, java.util.function.BiFunction<? super V, ? super V, ? extends V>)
but if this FiniteMap is full and this is a new key then just return false.- Parameters:
key
- key with which the resulting value is to be associatedvalue
- the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the keyremappingFunction
- the remapping function to recompute a value if present- Returns:
- A boolean indicating if there was room in the Map to merge this value.
-
size
public int size()
- Specified by:
size
in interfaceMap<String,Long>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceMap<String,Long>
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<String,Long>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<String,Long>
-
get
public Long get(Object key)
- Specified by:
get
in interfaceMap<String,Long>
-
put
public Long put(String key, Long value)
- Specified by:
put
in interfaceMap<String,Long>
-
remove
public Long remove(Object key)
- Specified by:
remove
in interfaceMap<String,Long>
-
putAll
public void putAll(Map<? extends String,? extends Long> m)
- Specified by:
putAll
in interfaceMap<String,Long>
-
clear
public void clear()
- Specified by:
clear
in interfaceMap<String,Long>
-
keySet
public Set<String> keySet()
- Specified by:
keySet
in interfaceMap<String,Long>
-
values
public Collection<Long> values()
- Specified by:
values
in interfaceMap<String,Long>
-
entrySet
public Set<Map.Entry<String,Long>> entrySet()
- Specified by:
entrySet
in interfaceMap<String,Long>
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceMap<String,Long>
- Overrides:
equals
in classObject
-
-