 |
Synthia
Generic and flexible data structure generator
|
Go to the documentation of this file.
19 package ca.uqac.lif.synthia.sequence;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collections;
24 import java.util.List;
27 import ca.
uqac.
lif.petitpoucet.ComposedPart;
28 import ca.
uqac.
lif.petitpoucet.NodeFactory;
31 import ca.
uqac.
lif.petitpoucet.function.ExplanationQueryable;
32 import ca.
uqac.
lif.petitpoucet.function.vector.NthElement;
88 @SuppressWarnings(
"unchecked")
101 @SuppressWarnings(
"unchecked")
112 @SuppressWarnings(
"unchecked")
228 PartNode root = f.getPartNode(p,
this);
230 Part head = p.head();
240 int actual_index = index %
m_values.length;
241 Part new_p = ComposedPart.compose(
new NthElement(actual_index),
new NthSuccessiveOutput(index));
242 root.addChild(f.getPartNode(new_p,
m_values));
249 StringBuilder out =
new StringBuilder();
250 out.append(
"Playback [");
251 for (
int i = 0; i <
m_values.length; i++)
260 return out.toString();
272 List<Integer> indices =
new ArrayList<Integer>();
273 int num_to_pick = (int) (m * (
float)
m_values.length);
274 while (indices.size() < num_to_pick)
276 int index = (int) Math.floor(d.
pick() *
m_values.length);
277 if (!indices.contains(index))
282 Collections.sort(indices);
283 List<T> values =
new ArrayList<T>(indices.size());
284 for (
int index : indices)
Playback< T > duplicate(boolean with_state)
Picks a random string.
Interface signaling that a picker can be shrunk.
Shrinkable< T > shrink(T o)
Shrinks a picker with default parameters.
T pick()
Picks the next value in the list of the Playback picker.
Playback(List< T > values)
Creates a new Playback picker.
PartNode getExplanation(Part p, NodeFactory f)
int m_index
The index of the current value.
T[] m_values
The values to play back.
PartNode getExplanation(Part p)
void reset()
Puts the Playback picker back into its initial state.
A variant of PickIf that selects an element if it is smaller than a reference object.
boolean m_loop
Whether to loop through the values.
static final transient RandomFloat instance
A public static instance of RandomFloat.
Picker that returns values taken from a list.
Signals that a picker can shrink the sequence of values it has produced since its last reset.
Pickers that produce pseudo-random objects such as numbers.
Playback< T > setLoop(boolean b)
Set the m_loop attribute of the playback picker.
Objects related to the explanation of results produced by pickers.
Interface used to signal that a picker enumerates all values from a set.
int m_startIndex
The start index.
Pickers that produce a value in relation to another value.
boolean isDone()
Signals if the playback picker picked all the objects from m_values.
SequenceShrinkable< T > shrink(Picker< Float > d, float m)
Shrinks a picker.
Picks a floating point number uniformly in an interval.
List< T > getSequence()
Gets the sequence of values that the picker has produced so far.
An exception to throw when a picker can't pick an other element.
Shrinkable< T > shrink(T o, Picker< Float > decision, float m)
Shrinks a picker.
A Part pointing to the n-th output produced by a picker since its last call to reset().