|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
ecologylab.generic.ObservableDebug
ecologylab.collections.WeightSet<E>
public class WeightSet<E extends AbstractSetElement>
Provides the facility of efficient weighted random selection from a set elements, each of whicn includes a characterizing floating point weight.
Works in cooperation w SetElements; requiring that user object to keep an integer
index slot, which only we should be accessing. This impure oo style is an adaption to Java's lack
of multiple inheritance.
Gotta be careful to be thread safe. Seems no operations can safely occur concurrently. There are a bunch of synchronized methods to affect this.
| Nested Class Summary | |
|---|---|
class |
WeightSet.FloatWeightComparator
|
| Constructor Summary | |
|---|---|
WeightSet(int maxSize,
int setSize,
WeightingStrategy<E> weightingStrategy)
|
|
WeightSet(int maxSize,
ThreadMaster threadMaster,
WeightingStrategy<E> weightStrategy)
|
|
WeightSet(WeightingStrategy<E> getWeightStrategy)
|
|
| Method Summary | |
|---|---|
E |
at(int i)
Fetches the i'th element in the sorted list. |
void |
clear(boolean doRecycleElements)
Delete all the elements in the set, as fast as possible. |
E |
get(int i)
|
double |
getWeight(E e)
Fetches the weight of the passed in element. |
WeightingStrategy<E> |
getWeightStrategy()
|
void |
insert(E el)
|
boolean |
isEmpty()
Check to see if the set has any elements. |
boolean |
isRunnable()
Method Overriden by VisualPool to return true |
java.util.Iterator<E> |
iterator()
|
E |
maxPeek()
|
E |
maxSelect()
Selects the top weighted element from the set. This method removes the selected from the set. |
double |
mean()
|
void |
prune(int numToKeep)
|
E |
pruneAndMaxSelect()
Prune to the set's specified maxSize, if necessary, then do a maxSelect(). |
void |
remove(E el)
|
int |
size()
|
java.lang.String |
toString()
|
java.lang.Double |
weightAt(int i)
Fetches the weight of the i'th element in the sorted list. |
| Methods inherited from class ecologylab.generic.ObservableDebug |
|---|
debug, debug, debugA, debugA, debugI, debugI, error, getClassName, print, println, println, println, show, superString |
| Methods inherited from class java.util.Observable |
|---|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public WeightSet(int maxSize,
int setSize,
WeightingStrategy<E> weightingStrategy)
public WeightSet(WeightingStrategy<E> getWeightStrategy)
public WeightSet(int maxSize,
ThreadMaster threadMaster,
WeightingStrategy<E> weightStrategy)
| Method Detail |
|---|
public double mean()
public E maxSelect()
public E maxPeek()
public void prune(int numToKeep)
public void insert(E el)
public void remove(E el)
public E get(int i)
public void clear(boolean doRecycleElements)
doRecycleElements - TODOpublic E pruneAndMaxSelect()
public int size()
public java.lang.String toString()
toString in class ObservableDebugpublic boolean isEmpty()
public E at(int i)
i - index into the list
public java.lang.Double weightAt(int i)
i - index into the list
public double getWeight(E e)
e - Element to weigh. Doesn't have to be a member of the set.
public boolean isRunnable()
VisualPool to return true
public WeightingStrategy<E> getWeightStrategy()
public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E extends AbstractSetElement>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||