 |
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.Collections;
23 import java.util.List;
25 import ca.
uqac.
lif.petitpoucet.NodeFactory;
28 import ca.
uqac.
lif.petitpoucet.function.ExplanationQueryable;
154 PartNode root = f.getPartNode(p,
this);
156 Part head = p.head();
161 if (index < 0 || index >
m_values.size())
166 root.addChild(f.getPartNode(p,
m_picker));
173 List<Integer> indices =
new ArrayList<Integer>();
174 int num_to_pick = (int) (m * (
float)
m_values.size());
175 while (indices.size() < num_to_pick)
177 int index = (int) Math.floor(d.
pick() *
m_values.size());
178 if (!indices.contains(index))
183 Collections.sort(indices);
184 List<T> values =
new ArrayList<T>(indices.size());
185 for (
int index : indices)
Picker that records and returns the values produced by another picker.
Record< T > duplicate(boolean with_state)
Creates a copy of the Record picker.
PartNode getExplanation(Part p, NodeFactory f)
SequenceShrinkable< T > shrink(Picker< Float > d, float m)
Shrinks a picker.
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.
boolean isDone()
Signals if the picker enumerates all values from a set.
Objects related to the explanation of results produced by pickers.
T pick()
Picks a value, records it and returns the value.
Interface used to signal that a picker enumerates all values from a set.
void clear()
Clears the values recorded so far.
PartNode getExplanation(Part p)
Picker< T > m_picker
The picker that generates the values.
List< T > getSequence()
Gets the sequence of values that the picker has produced so far.
void reset()
Puts the Record picker back into its initial state.
Record(Picker< T > picker)
Creates a new Record picker.
A Part pointing to the n-th output produced by a picker since its last call to reset().
List< T > m_values
The list of values produced by the picker so far.
int getCount()
Gets the number of values recorded by the picker so far.