![]() |
Synthia
Generic and flexible data structure generator
|
Picker that returns the first object fetched from another picker and repeats it endlessly.
For example, the following piece of code instantiates a RandomFloat r; the Freeze picker wraps around it, and keeps returning the first random float returned by r.
RandomFloat r = new RandomFloat(); Freeze<Float> f = new Freeze<Float>(r); float f1 = f.pick(); // 0.8104950, for example float f2 = f.pick(); // 0.8104950 again float f3 = f.pick(); // 0.8104950 again ...
| <T> | The type of objects to pick |
Definition at line 48 of file Freeze.java.

Public Member Functions | |
| Freeze (Picker< T > picker) | |
| Creates a new freeze picker. More... | |
| void | reset () |
| Puts the freeze picker back into its initial state. More... | |
| T | pick () |
| Picks a value or returns the same value if m_value is not null. More... | |
| Freeze< T > | duplicate (boolean with_state) |
| Creates a copy of the picker. More... | |
| Shrinkable< T > | shrink (T o, Picker< Float > decision, float m) |
| Shrinks a picker. More... | |
| PartNode | getExplanation (Part p) |
| PartNode | getExplanation (Part p, NodeFactory f) |
| String | toString () |
| Shrinkable< T > | shrink (T o) |
| Shrinks a picker with default parameters. More... | |
Protected Attributes | |
| Picker< T > | m_innerPicker |
| The internal picker that is to be called. More... | |
| T | m_value = null |
| The "frozen" value. More... | |
| ca.uqac.lif.synthia.util.Freeze< T >.Freeze | ( | Picker< T > | picker | ) |
Creates a new freeze picker.
| picker | The underlying picker used to get the first value |
Definition at line 65 of file Freeze.java.
| Freeze<T> ca.uqac.lif.synthia.util.Freeze< T >.duplicate | ( | boolean | with_state | ) |
Creates a copy of the picker.
| with_state | If 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. |
Implements ca.uqac.lif.synthia.Picker< T >.
Definition at line 104 of file Freeze.java.
| PartNode ca.uqac.lif.synthia.util.Freeze< T >.getExplanation | ( | Part | p | ) |
Definition at line 121 of file Freeze.java.
| PartNode ca.uqac.lif.synthia.util.Freeze< T >.getExplanation | ( | Part | p, |
| NodeFactory | f | ||
| ) |
Definition at line 127 of file Freeze.java.
| T ca.uqac.lif.synthia.util.Freeze< T >.pick | ( | ) |
Picks a value or returns the same value if m_value is not null.
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.
Implements ca.uqac.lif.synthia.Picker< T >.
Definition at line 94 of file Freeze.java.
| void ca.uqac.lif.synthia.util.Freeze< T >.reset | ( | ) |
Puts the freeze 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 78 of file Freeze.java.
| Shrinkable<T> ca.uqac.lif.synthia.util.Freeze< T >.shrink | ( | T | o | ) |
Shrinks a picker with default parameters.
For any picker p that implements the Shrinkable interface, a call to p.shrink(o) should be the same as a call to p.shrink(o, RandomFloat.instance, 1).
| o | The reference object. The picker must guarantee that the returned picker instance only produces objects that are smaller than o, according to an implicit ordering relation that is specific to each object type and each picker. |
Implements ca.uqac.lif.synthia.Shrinkable< T >.
Definition at line 143 of file Freeze.java.
| Shrinkable<T> ca.uqac.lif.synthia.util.Freeze< T >.shrink | ( | T | o, |
| Picker< Float > | d, | ||
| float | m | ||
| ) |
Shrinks a picker.
The method adds two arguments with respect to shrink(Object): a source of randomness and a magnitude parameter. A picker may use the magnitude to determine how "aggressive" is the shrinking process. A value of 1 is expected to produce a picker with the broadest set, and may return all possible objects that are smaller than the reference. Lower values (all the way down to 0) instruct the picker to exclude further objects, and typically to only produce objects that are relatively "much smaller" than the reference.
| o | The reference object. The picker must guarantee that the returned picker instance only produces objects that are smaller than o, according to an implicit ordering relation that is specific to each object type and each picker. |
| d | A source of randomness. Some pickers must make choices when producing shrunk objects, and this parameter is used as an external source for these choices. |
| m | A magnitude parameter, which must be between 0 and 1. |
Implements ca.uqac.lif.synthia.Shrinkable< T >.
Definition at line 115 of file Freeze.java.
| String ca.uqac.lif.synthia.util.Freeze< T >.toString | ( | ) |
Definition at line 136 of file Freeze.java.
|
protected |
The internal picker that is to be called.
Definition at line 53 of file Freeze.java.
|
protected |
The "frozen" value.
Definition at line 58 of file Freeze.java.