org.encog.util.obj
Class ChooseObject<T>

java.lang.Object
  extended by org.encog.util.obj.ChooseObject<T>
Type Parameters:
T - The type of object to choose from.
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
OperationList

public class ChooseObject<T>
extends Object
implements Serializable

This class is used to choose between several objects with a specified probability.

See Also:
Serialized Form

Constructor Summary
ChooseObject()
           
 
Method Summary
 void add(double probability, T opp)
          Add an object.
 void clear()
          CLear all objects from the collection.
 void finalizeStructure()
          Finalize the structure and set the probabilities.
 List<ObjectHolder<T>> getList()
           
 T pick(Random theGenerator)
          Choose a random object.
 T pickFirst()
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChooseObject

public ChooseObject()
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(Random theGenerator)
Choose a random object.

Parameters:
theGenerator -
Returns:
The random choice.

getList

public 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.


Copyright © 2014. All Rights Reserved.