- java.lang.Object
-
- org.chocosolver.util.objects.ValueSortedMap<E>
-
- Type Parameters:
E
- key's type
public class ValueSortedMap<E> extends Object
A map which ensures key uniqueness and order over values.- Since:
- 30/01/2017.
- Author:
- Charles Prud'homme
-
-
Constructor Summary
Constructors Constructor Description ValueSortedMap()
Create a doubly-linked set E <-> value, where value is a int.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Remove all entries from this map.int
getLastValue()
return the largest value stored in thisint
getLowerValue(int value)
return the lowest value stored in thisint
getValue(E k)
int
getValueOrDefault(E k, int defaultValue)
boolean
isEmpty()
int
pollLastValue()
return and remove the largest value stored in thisvoid
put(E k, int v)
Insert a key k with the value v in this.void
remove(E k)
Remove the keyk and its value from thisboolean
removeIf(Predicate<? super E> filter)
Remove any key and its value that matches the predicate filtervoid
replace(E k, int v)
Replaces the value attached with key k with v.
-
-
-
Method Detail
-
clear
public void clear()
Remove all entries from this map.
-
put
public void put(E k, int v)
Insert a key k with the value v in this. If the key already exists, it is replaced.- Parameters:
k
- the keyv
- the value
-
replace
public void replace(E k, int v)
Replaces the value attached with key k with v.- Parameters:
k
- the keyv
- the value
-
getValue
public int getValue(E k)
- Parameters:
k
- a key- Returns:
- value attached to the key k, or
NO_ENTRY
otherwise.
-
getValueOrDefault
public int getValueOrDefault(E k, int defaultValue)
- Parameters:
k
- a keydefaultValue
- value to return if k is not known.- Returns:
- value attached to the key k, or defaultValue otherwise.
-
getLastValue
public int getLastValue()
return the largest value stored in this- Returns:
- the largest value stored in this
-
getLowerValue
public int getLowerValue(int value)
return the lowest value stored in this- Returns:
- the lowest value stored in this
-
pollLastValue
public int pollLastValue()
return and remove the largest value stored in this- Returns:
- the largest value stored in this
-
remove
public void remove(E k)
Remove the keyk and its value from this- Parameters:
k
- a key
-
removeIf
public boolean removeIf(Predicate<? super E> filter)
Remove any key and its value that matches the predicate filter- Parameters:
filter
- predicate that satisfies (key,value) to remove
-
isEmpty
public boolean isEmpty()
- Returns:
- true if this is empty
-
-