|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.dishevelled.weighted.HashWeightedMap<E>
E - the type of elements maintained by this weighted mappublic final class HashWeightedMap<E>
Implementation of WeightedMap that delegates to a HashMap.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
HashWeightedMap()
Create a new weighted map with the default initial capacity and load factor. |
|
HashWeightedMap(int initialCapacity)
Create a new weighted map with the specified initial capacity and default load factor. |
|
HashWeightedMap(int initialCapacity,
float loadFactor)
Create a new weighted map with the specified initial capacity and load factor. |
|
HashWeightedMap(WeightedMap<? extends E> weightedMap)
Create a new weighted map with the elements and weights in the specified weighted map (copy constructor). |
|
| Method Summary | |
|---|---|
void |
clear()
|
boolean |
containsKey(Object o)
|
boolean |
containsValue(Object o)
|
Set<Map.Entry<E,Double>> |
entrySet()
|
Double |
get(Object o)
|
boolean |
isEmpty()
|
Set<E> |
keySet()
|
int |
maximumRank()
Return the maximum rank in this weighted map. |
Double |
normalizedWeight(E e)
Return the normalized weight for the specified element in this weighted map. |
Double |
put(E e,
Double w)
|
void |
putAll(Map<? extends E,? extends Double> t)
|
int |
rank(E e)
Return an integer rank for the specified element in this weighted map based on its weight. |
Double |
remove(Object o)
|
E |
sample()
Randomly sample an element from this weighted map according to its normalized weight. |
void |
setRandom(Random random)
Set the source of randomness for this weighted map to random. |
int |
size()
|
Double |
totalWeight()
Return the sum of the weights in this weighted map. |
Collection<Double> |
values()
|
Double |
weight(E e)
Return the weight for the specified element in this weighted map. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public HashWeightedMap()
public HashWeightedMap(int initialCapacity)
initialCapacity - initial capacity
public HashWeightedMap(int initialCapacity,
float loadFactor)
initialCapacity - initial capacityloadFactor - load factorpublic HashWeightedMap(WeightedMap<? extends E> weightedMap)
weightedMap - weighted map to copy, must not be null| Method Detail |
|---|
public void setRandom(Random random)
random.
random - source of randomness, must not be nullpublic void clear()
clear in interface Map<E,Double>public int size()
size in interface Map<E,Double>public boolean isEmpty()
isEmpty in interface Map<E,Double>public boolean containsKey(Object o)
containsKey in interface Map<E,Double>public boolean containsValue(Object o)
containsValue in interface Map<E,Double>public Double get(Object o)
get in interface Map<E,Double>
public Double put(E e,
Double w)
put in interface Map<E,Double>public void putAll(Map<? extends E,? extends Double> t)
putAll in interface Map<E,Double>public Double remove(Object o)
remove in interface Map<E,Double>public E sample()
sample in interface WeightedMap<E>null if this weighted
map is empty or if the total weight is zeroWeightedMap.totalWeight(),
WeightedMap.normalizedWeight(E)public Double weight(E e)
get(E e).
weight in interface WeightedMap<E>e - element
null if this weighted map is emptypublic Double normalizedWeight(E e)
normalizedWeight in interface WeightedMap<E>e - element
null if this weighted map is emptypublic Double totalWeight()
totalWeight in interface WeightedMap<E>public int rank(E e)
rank in interface WeightedMap<E>e - element
-1 if this
weighted map is empty or if e is not an element
in this weighted mappublic int maximumRank()
maximumRank in interface WeightedMap<E>-1 if this weighted map is emptypublic Set<E> keySet()
keySet in interface Map<E,Double>public Collection<Double> values()
values in interface Map<E,Double>public Set<Map.Entry<E,Double>> entrySet()
entrySet in interface Map<E,Double>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||