![]() |
Synthia
Generic and flexible data structure generator
|
Picker that returns values taken from a list.
As its name implies, Playback literally replays the values fetched from a list that was passed to its constructor. It loops back to the beginning when the list is over (this can optionally be disabled).
Playback<Integer> p = new Playback<Integer>(2, 7, 1); System.out.println(p.pick()); // 2 System.out.println(p.pick()); // 7 System.out.println(p.pick()); // 1 System.out.println(p.pick()); // 2 ...
Optionally, the picker can be told to start at a different element than the first one. By default, the picker keeps outputting the last value of the sequence if more values are requested and the loop parameter is set to false.
| <T> | The type of objects to return |
Definition at line 61 of file Playback.java.

Public Member Functions | |
| Playback (int start_index, T ... values) | |
| Creates a new Playback picker. More... | |
| Playback (T ... values) | |
| Creates a new Playback picker. More... | |
| Playback (int start_index, List< T > values) | |
| Creates a new Playback picker. More... | |
| Playback (List< T > values) | |
| Creates a new Playback picker. More... | |
| T | pick () |
| Picks the next value in the list of the Playback picker. More... | |
| void | reset () |
| Puts the Playback picker back into its initial state. More... | |
| Playback< T > | duplicate (boolean with_state) |
| Picks a random string. More... | |
| Playback< T > | setLoop (boolean b) |
| Set the m_loop attribute of the playback picker. More... | |
| boolean | isDone () |
| Signals if the playback picker picked all the objects from m_values. 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... | |
| SequenceShrinkable< T > | shrink (Picker< Float > d, float m) |
| Shrinks a picker. More... | |
| List< T > | getSequence () |
| Gets the sequence of values that the picker has produced so far. More... | |
Protected Attributes | |
| T[] | m_values |
| The values to play back. More... | |
| int | m_index |
| The index of the current value. More... | |
| int | m_startIndex |
| The start index. More... | |
| boolean | m_loop |
| Whether to loop through the values. More... | |
| ca.uqac.lif.synthia.sequence.Playback< T >.Playback | ( | int | start_index, |
| T ... | values | ||
| ) |
Creates a new Playback picker.
| start_index | The position of the first value to return |
| values | The values to play back |
Definition at line 89 of file Playback.java.
| ca.uqac.lif.synthia.sequence.Playback< T >.Playback | ( | T ... | values | ) |
Creates a new Playback picker.
| values | The values to play back |
Definition at line 102 of file Playback.java.
| ca.uqac.lif.synthia.sequence.Playback< T >.Playback | ( | int | start_index, |
| List< T > | values | ||
| ) |
Creates a new Playback picker.
| start_index | The position of the first value to return |
| values | The values to play back |
Definition at line 113 of file Playback.java.
| ca.uqac.lif.synthia.sequence.Playback< T >.Playback | ( | List< T > | values | ) |
Creates a new Playback picker.
| values | The values to play back |
Definition at line 124 of file Playback.java.
| Playback<T> ca.uqac.lif.synthia.sequence.Playback< T >.duplicate | ( | boolean | with_state | ) |
Picks a random string.
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 >.
Reimplemented in ca.uqac.lif.synthia.enumerative.AllElements< T >.
Definition at line 175 of file Playback.java.
| PartNode ca.uqac.lif.synthia.sequence.Playback< T >.getExplanation | ( | Part | p | ) |
Definition at line 220 of file Playback.java.
| PartNode ca.uqac.lif.synthia.sequence.Playback< T >.getExplanation | ( | Part | p, |
| NodeFactory | f | ||
| ) |
Definition at line 226 of file Playback.java.
| List<T> ca.uqac.lif.synthia.sequence.Playback< T >.getSequence | ( | ) |
Gets the sequence of values that the picker has produced so far.
Implements ca.uqac.lif.synthia.SequenceShrinkable< T >.
Definition at line 292 of file Playback.java.
| boolean ca.uqac.lif.synthia.sequence.Playback< T >.isDone | ( | ) |
Signals if the playback picker picked all the objects from m_values.
Loop attributes must be false. If loop is true, the method will always return false.
Implements ca.uqac.lif.synthia.Bounded< T >.
Reimplemented in ca.uqac.lif.synthia.enumerative.AllElements< T >.
Definition at line 208 of file Playback.java.
| T ca.uqac.lif.synthia.sequence.Playback< T >.pick | ( | ) |
Picks the next value in the list of the Playback picker.
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 >.
Reimplemented in ca.uqac.lif.synthia.enumerative.AllElements< T >.
Definition at line 138 of file Playback.java.
| void ca.uqac.lif.synthia.sequence.Playback< T >.reset | ( | ) |
Puts the Playback 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 >.
Reimplemented in ca.uqac.lif.synthia.enumerative.AllElements< T >.
Definition at line 160 of file Playback.java.
| Playback<T> ca.uqac.lif.synthia.sequence.Playback< T >.setLoop | ( | boolean | b | ) |
Set the m_loop attribute of the playback picker.
If the attribute is set to false, the next call to the pick() method will return a NoMoreElementException after producing the last element of the list.
| b | boolean value to enable playback loop or not |
Definition at line 196 of file Playback.java.
| SequenceShrinkable<T> ca.uqac.lif.synthia.sequence.Playback< T >.shrink | ( | Picker< Float > | d, |
| float | magnitude | ||
| ) |
Shrinks a picker.
The method has two arguments: 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 any subsequence of its past values. Lower values (all the way down to 0) instruct the picker to exclude further elements, and typically to only produce sub-sequences that are relatively "much smaller" than the reference.
| d | A source of randomness. Some pickers must make choices when producing shrunk sequences, and this parameter is used as an external source for these choices. |
| magnitude | A magnitude parameter, which must be between 0 and 1. |
Implements ca.uqac.lif.synthia.SequenceShrinkable< T >.
Definition at line 270 of file Playback.java.
| Shrinkable<T> ca.uqac.lif.synthia.sequence.Playback< 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 264 of file Playback.java.
| Shrinkable<T> ca.uqac.lif.synthia.sequence.Playback< 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 214 of file Playback.java.
| String ca.uqac.lif.synthia.sequence.Playback< T >.toString | ( | ) |
Definition at line 247 of file Playback.java.
|
protected |
The index of the current value.
Definition at line 71 of file Playback.java.
|
protected |
Whether to loop through the values.
Definition at line 81 of file Playback.java.
|
protected |
The start index.
Definition at line 76 of file Playback.java.
|
protected |
The values to play back.
Definition at line 66 of file Playback.java.