Synthia
Generic and flexible data structure generator
ca.uqac.lif.synthia.util.Once< T > Class Template Reference

Detailed Description

Picker that returns the first value fetched from another picker, and then null afterwards.

For example, the following piece of code instantiates a RandomFloat r; the Once picker wraps around it, returns the first random float returned by r, and then null on subsequent calls.

RandomFloat r = new RandomFloat();
Once<Float> f = new Once<Float>(r);
float f1 = f.pick(); // 0.8104950, for example
float f2 = f.pick(); // null
float f3 = f.pick(); // null again
...

Note that a call to reset() will cause the picker to return a non-null object on its next call to pick().

Parameters
<T>The type of object to pick

Definition at line 45 of file Once.java.

Inheritance diagram for ca.uqac.lif.synthia.util.Once< T >:

Public Member Functions

 Once (Picker< T > picker)
 Creates a new Once picker. More...
 
void reset ()
 Puts the once picker back into its initial state. More...
 
pick ()
 Picks a random value. More...
 
Once< T > duplicate (boolean with_state)
 Creates a copy of the once picker. More...
 

Constructor & Destructor Documentation

◆ Once()

ca.uqac.lif.synthia.util.Once< T >.Once ( Picker< T >  picker)

Creates a new Once picker.

Parameters
pickerThe underlying picker used to get the first value

Definition at line 62 of file Once.java.

Member Function Documentation

◆ duplicate()

Once<T> ca.uqac.lif.synthia.util.Once< T >.duplicate ( boolean  with_state)

Creates a copy of the once picker.

Parameters
with_stateIf set to false, the returned copy is set to the class' initial state (i.e. same thing as calling the picker's constructor). If set to true, the returned copy is put into the same internal state as the object it is copied from.
Returns
The copy of the RandomString picker

Implements ca.uqac.lif.synthia.Picker< T >.

Definition at line 113 of file Once.java.

◆ pick()

Picks a random value.

Typically, this method is expected to return non-null objects; a null return value is used to signal that no more objects will be produced. That is, once this method returns null, it should normally return null on all subsequent calls.

Returns
The random string.

Implements ca.uqac.lif.synthia.Picker< T >.

Definition at line 93 of file Once.java.

◆ reset()

void ca.uqac.lif.synthia.util.Once< T >.reset ( )

Puts the once picker back into its initial state.

This means that the sequence of calls to pick() will produce the same values as when the object was instantiated.

Implements ca.uqac.lif.synthia.Picker< T >.

Definition at line 76 of file Once.java.


The documentation for this class was generated from the following file: