org.encog.util.obj
Class ChooseObject<T>
- java.lang.Object
-
- org.encog.util.obj.ChooseObject<T>
-
- Type Parameters:
T- The type of object to choose from.
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- OperationList
public class ChooseObject<T> extends java.lang.Object implements java.io.SerializableThis class is used to choose between several objects with a specified probability.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ChooseObject()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(double probability, T opp)Add an object.voidclear()CLear all objects from the collection.voidfinalizeStructure()Finalize the structure and set the probabilities.java.util.List<ObjectHolder<T>>getList()Tpick(java.util.Random theGenerator)Choose a random object.TpickFirst()intsize()
-
-
-
Method Detail
-
finalizeStructure
public void finalizeStructure()
Finalize the structure and set the probabilities.
-
add
public void add(double probability, T opp)Add an object.- Parameters:
probability- The probability to choose this object.opp- The object to add.
-
size
public int size()
- Returns:
- The number of objects added.
-
pick
public T pick(java.util.Random theGenerator)
Choose a random object.- Parameters:
theGenerator- Random number generator.- Returns:
- The random choice.
-
getList
public java.util.List<ObjectHolder<T>> getList()
- Returns:
- The object to choose from.
-
clear
public void clear()
CLear all objects from the collection.
-
pickFirst
public T pickFirst()
- Returns:
- The first object in the list.
-
-
DMelt 3.0 © DataMelt by jWork.ORG