![]() |
Synthia
Generic and flexible data structure generator
|
Picker producing an "interleaved" sequence of objects from calls to multiple other pickers.
The Knit picker must be instantiated by passing to it a picker of pickers p (that is, a Picker<Picker<T>>). Upon every call to pick(), Knit proceeds as follows:
Picker<T>; if so, it calls p.pick() and adds the resulting picker instance to its set of "living" pickers. Knit flips a coin to to decide whether to create a new instance of Picker<T> to replace it; if so, it calls p.pick() and adds the resulting picker instance to its set of "living" pickers. | <T> | The type of the objects to produce |

Public Member Functions | |
| Knit (Picker<? extends Picker< T >> instance_picker, Picker< Boolean > new_instance, Picker< Boolean > renew_instance, Picker< Float > float_source) | |
| Creates a new instance of the picker. More... | |
| void | reset () |
| Puts the picker back into its initial state. More... | |
| T | pick () |
| Picks an object. More... | |
| Knit< T > | duplicate (boolean with_state) |
| Creates a copy of the picker. More... | |
| String | toString () |
Protected Attributes | |
| Picker<? extends Picker< T > > | m_instancePicker |
| A picker producing pickers. More... | |
| Picker< Boolean > | m_newInstance |
| A picker deciding whether to start a new instance at any moment. More... | |
| Picker< Boolean > | m_renewInstance |
| A picker deciding whether to start a new instance when one has just finished. More... | |
| Picker< Float > | m_floatSource |
| A picker used to pick a living instance. More... | |
| List< Picker< T > > | m_instances |
| The picker instances that are currently "alive". More... | |
Static Protected Attributes | |
| static final transient int | s_maxTries = 1000 |
| Maximum number of tries to get a new element from an instance before giving up. More... | |
| ca.uqac.lif.synthia.sequence.Knit< T >.Knit | ( | Picker<? extends Picker< T >> | instance_picker, |
| Picker< Boolean > | new_instance, | ||
| Picker< Boolean > | renew_instance, | ||
| Picker< Float > | float_source | ||
| ) |
Creates a new instance of the picker.
| instance_picker | A picker producing picker instances |
| new_instance | A picker deciding whether to start a new instance at any moment |
| renew_instance | A picker deciding whether to start a new instance when one has just finished |
| float_source | A picker used to pick a living instance |
| Knit<T> ca.uqac.lif.synthia.sequence.Knit< 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 >.
| T ca.uqac.lif.synthia.sequence.Knit< T >.pick | ( | ) |
Picks an object.
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 >.
| void ca.uqac.lif.synthia.sequence.Knit< T >.reset | ( | ) |
Puts the 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 >.
| String ca.uqac.lif.synthia.sequence.Knit< T >.toString | ( | ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |