Package ptolemy.cg.lib.syntactic
Class SyntacticSeries
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.AbstractSequentialList<E>
-
- java.util.LinkedList<SyntacticTerm>
-
- ptolemy.cg.lib.syntactic.SyntacticTermList
-
- ptolemy.cg.lib.syntactic.SyntacticSeries
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<SyntacticTerm>
,java.util.Collection<SyntacticTerm>
,java.util.Deque<SyntacticTerm>
,java.util.List<SyntacticTerm>
,java.util.Queue<SyntacticTerm>
,SyntacticTerm
public class SyntacticSeries extends SyntacticTermList
This class represents a series composition over a sequence of SyntacticTerms. Each term in the sequence is composed with the previous to form a chain of operations. Each output is connected in order with each input of the subsequent term. The term produced by this composition has a number of inputs equal to that of the first term in the sequence, and a number of outputs equal to that of the last term. The chain is initialized as empty, and terms can be added to it either pushing to the end, or by insertion. In these operations, checking is done to enforce the constraint that the number of inputs and outputs are equal at a composition. Removal is possible, although only when a term is has the same number of inputs as outputs.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Chris Shaver
- See Also:
- Serialized Form
- Pt.AcceptedRating:
- Red
- Pt.ProposedRating:
- Red (shaver)
-
-
Field Summary
-
Fields inherited from class ptolemy.cg.lib.syntactic.SyntacticTermList
_inputs, _outputs, _rank
-
-
Constructor Summary
Constructors Constructor Description SyntacticSeries()
Create an empty SyntacticSeries term.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, SyntacticTerm term)
Adds a term to an arbitrary position of the series.boolean
add(SyntacticTerm term)
Add a term to the end of the series.java.lang.String
generateCode()
Generate code for the series.void
intercolatePermutations()
Intercolate permutations between series terms.void
push(SyntacticTerm term)
Pushes a term to the end of the series.boolean
remove(SyntacticTerm term)
Removes a term from the series.-
Methods inherited from class ptolemy.cg.lib.syntactic.SyntacticTermList
_refreshPorts, _refreshRank, addAll, clear, getInputs, getOrder, getOutputs, hasCode, inputIndex, outputIndex, rank, remove, remove, removeAll, set, sizeInputs, sizeOutputs
-
Methods inherited from class java.util.LinkedList
addAll, addFirst, addLast, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size, spliterator, toArray, toArray
-
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
-
-
-
-
Method Detail
-
add
public boolean add(SyntacticTerm term)
Add a term to the end of the series. This is only allowed if the added term has as many inputs as the currently last term has outputs. Otherwise, false is returned and nothing is done.- Specified by:
add
in interfacejava.util.Collection<SyntacticTerm>
- Specified by:
add
in interfacejava.util.Deque<SyntacticTerm>
- Specified by:
add
in interfacejava.util.List<SyntacticTerm>
- Specified by:
add
in interfacejava.util.Queue<SyntacticTerm>
- Overrides:
add
in classSyntacticTermList
- Parameters:
term
- Term to be added to series.- Returns:
- true if added, false if invalid.
-
push
public void push(SyntacticTerm term)
Pushes a term to the end of the series. This is only allowed if the added term has as many inputs as the currently last term has outputs. Otherwise, false is returned and nothing is done.- Specified by:
push
in interfacejava.util.Deque<SyntacticTerm>
- Overrides:
push
in classjava.util.LinkedList<SyntacticTerm>
- Parameters:
term
- Term to be added to series.
-
add
public void add(int index, SyntacticTerm term)
Adds a term to an arbitrary position of the series. This is allowed only if the added term is compatible with neighboring terms. If not at the beginning or end, this essentially means it must have the same number of inputs and outputs.- Specified by:
add
in interfacejava.util.List<SyntacticTerm>
- Overrides:
add
in classSyntacticTermList
- Parameters:
index
- Index at which to add the term.term
- Term to add to series.
-
remove
public boolean remove(SyntacticTerm term)
Removes a term from the series. This can only be done if the neighboring terms can be connected with each other. In the case that this is an interior term, it must have the same number of inputs and outputs to complete this operation.- Parameters:
term
- Term to remove from series.- Returns:
- whether term has been removed.
-
intercolatePermutations
public void intercolatePermutations()
Intercolate permutations between series terms.
-
generateCode
public java.lang.String generateCode()
Generate code for the series. The code for each term are joined by series composition operators.- Specified by:
generateCode
in interfaceSyntacticTerm
- Overrides:
generateCode
in classSyntacticTermList
- Returns:
- code for term.
-
-