Package ptolemy.cg.lib.syntactic
Class SyntacticTermList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.AbstractSequentialList<E>
-
- java.util.LinkedList<SyntacticTerm>
-
- ptolemy.cg.lib.syntactic.SyntacticTermList
-
- 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
- Direct Known Subclasses:
SyntacticColumn,SyntacticSeries
public class SyntacticTermList extends java.util.LinkedList<SyntacticTerm> implements SyntacticTerm
This class is the base class for SyntacticTerms that are formed from operations on lists of other terms. Since, it extends LinkedList, it internally maintains a list of SyntacticTerms, although not semantics are given to the list other than the collective access to the ports of its elements. Additional information and structure to form an operator should override or extend the methods of this base class to correctly calculate rank, connectivity, and other combinator behaviors.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Chris Shaver
- See Also:
- Serialized Form
- Pt.AcceptedRating:
- Red
- Pt.ProposedRating:
- Red (shaver)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.LinkedList<SyntacticPort>_inputsList of exposed input ports of constituent terms.protected java.util.LinkedList<SyntacticPort>_outputsList of exposed output ports of constituent terms.protected SyntacticRank_rankRank of list as a term.
-
Constructor Summary
Constructors Constructor Description SyntacticTermList()Constructs an empty term list with no rank information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_refreshPorts()Refresh the port lists scanning through the terms.protected void_refreshRank()Recalculate the rank of the list as a term.voidadd(int index, SyntacticTerm term)Insert a Syntactic Term in the column.booleanadd(SyntacticTerm term)Add a Syntactic Term to the column.booleanaddAll(java.util.Collection<? extends SyntacticTerm> terms)Add collection of SyntacticTerms to the list by calling the add function.voidclear()Clear list along with port lists.java.lang.StringgenerateCode()Generate code for the term.java.util.List<SyntacticPort>getInputs()Get all of the output ports for a column.intgetOrder()Get the sort order of the term.java.util.List<SyntacticPort>getOutputs()Get all of the output ports for a column.booleanhasCode()Decide whether the term has code to generate.java.lang.IntegerinputIndex(SyntacticPort port)Get the index of the syntactic input port in the column.java.lang.IntegeroutputIndex(SyntacticPort port)Get the index of the syntactic output port in the column.SyntacticRankrank()Get the rank of the list.SyntacticTermremove(int index)Remove a term at a given index.booleanremove(java.lang.Object ot)Remove a Syntactic Term from column.booleanremoveAll(java.util.Collection<?> terms)Remove collection of SyntacticTerms to the list by calling the remove function.SyntacticTermset(int index, SyntacticTerm term)Overwrite a Syntactic Term in the column.intsizeInputs()Get the number of inputs to the elements of the list exposed to the outside.intsizeOutputs()Get the number of outputs to the elements of the list exposed to the outside.-
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, push, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size, spliterator, toArray, toArray
-
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
-
-
-
-
Field Detail
-
_inputs
protected java.util.LinkedList<SyntacticPort> _inputs
List of exposed input ports of constituent terms.
-
_outputs
protected java.util.LinkedList<SyntacticPort> _outputs
List of exposed output ports of constituent terms.
-
_rank
protected SyntacticRank _rank
Rank of list as a term.
-
-
Method Detail
-
add
public boolean add(SyntacticTerm term)
Add a Syntactic Term to the column. Inputs and outputs are added to the total inputs and outputs of the composition.This method overrides the LinkedList add().
- Specified by:
addin interfacejava.util.Collection<SyntacticTerm>- Specified by:
addin interfacejava.util.Deque<SyntacticTerm>- Specified by:
addin interfacejava.util.List<SyntacticTerm>- Specified by:
addin interfacejava.util.Queue<SyntacticTerm>- Overrides:
addin classjava.util.LinkedList<SyntacticTerm>- Parameters:
term- Term to add to the composition.- Returns:
- whether node was added.
-
addAll
public boolean addAll(java.util.Collection<? extends SyntacticTerm> terms)
Add collection of SyntacticTerms to the list by calling the add function. If add is overridden then this will polymorphically apply it repeatedly to collections.- Specified by:
addAllin interfacejava.util.Collection<SyntacticTerm>- Specified by:
addAllin interfacejava.util.Deque<SyntacticTerm>- Specified by:
addAllin interfacejava.util.List<SyntacticTerm>- Overrides:
addAllin classjava.util.LinkedList<SyntacticTerm>- Parameters:
terms- Terms is a collection of SyntacticTerms.- Returns:
- whether or not operation changed list.
-
removeAll
public boolean removeAll(java.util.Collection<?> terms)
Remove collection of SyntacticTerms to the list by calling the remove function. If add is overridden then this will polymorphically apply it repeatedly to collections.- Specified by:
removeAllin interfacejava.util.Collection<SyntacticTerm>- Specified by:
removeAllin interfacejava.util.List<SyntacticTerm>- Overrides:
removeAllin classjava.util.AbstractCollection<SyntacticTerm>- Parameters:
terms- Terms is a collection of SyntacticTerms.- Returns:
- whether or not operation changed list.
-
add
public void add(int index, SyntacticTerm term)Insert a Syntactic Term in the column. Inputs and outputs are added to the total inputs and outputs of the composition.This method overrides the LinkedList add().
- Specified by:
addin interfacejava.util.List<SyntacticTerm>- Overrides:
addin classjava.util.LinkedList<SyntacticTerm>- Parameters:
index- Index at which to add the term.term- Term to add to the composition.
-
remove
public boolean remove(java.lang.Object ot)
Remove a Syntactic Term from column. Inputs and outputs are removed from the total inputs and outputs.This method overrides the LinkedList remove.
- Specified by:
removein interfacejava.util.Collection<SyntacticTerm>- Specified by:
removein interfacejava.util.Deque<SyntacticTerm>- Specified by:
removein interfacejava.util.List<SyntacticTerm>- Overrides:
removein classjava.util.LinkedList<SyntacticTerm>- Parameters:
ot- Term to be removed from the composition.- Returns:
- whether term was removed.
-
clear
public void clear()
Clear list along with port lists.- Specified by:
clearin interfacejava.util.Collection<SyntacticTerm>- Specified by:
clearin interfacejava.util.List<SyntacticTerm>- Overrides:
clearin classjava.util.LinkedList<SyntacticTerm>
-
set
public SyntacticTerm set(int index, SyntacticTerm term)
Overwrite a Syntactic Term in the column. Inputs and outputs are added to the total inputs and outputs of the list.- Specified by:
setin interfacejava.util.List<SyntacticTerm>- Overrides:
setin classjava.util.LinkedList<SyntacticTerm>- Parameters:
index- Index at which to overwrite the term.term- Term with which the term at the given index is replaced.- Returns:
- term replaced.
-
remove
public SyntacticTerm remove(int index)
Remove a term at a given index.- Specified by:
removein interfacejava.util.List<SyntacticTerm>- Overrides:
removein classjava.util.LinkedList<SyntacticTerm>- Parameters:
index- Index at which to remove the term.- Returns:
- term that has been removed.
-
getInputs
public java.util.List<SyntacticPort> getInputs()
Get all of the output ports for a column.- Specified by:
getInputsin interfaceSyntacticTerm- Returns:
- A list of input ports for the column.
-
getOutputs
public java.util.List<SyntacticPort> getOutputs()
Get all of the output ports for a column.- Specified by:
getOutputsin interfaceSyntacticTerm- Returns:
- A list of input ports for the column.
-
sizeInputs
public int sizeInputs()
Get the number of inputs to the elements of the list exposed to the outside.- Specified by:
sizeInputsin interfaceSyntacticTerm- Returns:
- number of inputs.
-
sizeOutputs
public int sizeOutputs()
Get the number of outputs to the elements of the list exposed to the outside.- Specified by:
sizeOutputsin interfaceSyntacticTerm- Returns:
- number of outputs.
-
rank
public SyntacticRank rank()
Get the rank of the list.- Specified by:
rankin interfaceSyntacticTerm- Returns:
- rank of the list as a term.
-
inputIndex
public java.lang.Integer inputIndex(SyntacticPort port)
Get the index of the syntactic input port in the column. If the given port is not in the inputs for the column null is returned.- Specified by:
inputIndexin interfaceSyntacticTerm- Parameters:
port- Port to find the index of.- Returns:
- index of the port or null.
-
outputIndex
public java.lang.Integer outputIndex(SyntacticPort port)
Get the index of the syntactic output port in the column. If the given port is not in the outputs for the column null is returned.- Specified by:
outputIndexin interfaceSyntacticTerm- Parameters:
port- Port to find the index of.- Returns:
- index of the port or null.
-
generateCode
public java.lang.String generateCode()
Generate code for the term. In the case of this base class it is blank.- Specified by:
generateCodein interfaceSyntacticTerm- Returns:
- string containing the code for the term.
-
getOrder
public int getOrder()
Get the sort order of the term.- Specified by:
getOrderin interfaceSyntacticTerm- Returns:
- sort order of the term.
-
hasCode
public boolean hasCode()
Decide whether the term has code to generate.- Specified by:
hasCodein interfaceSyntacticTerm- Returns:
- whether the term has code to generate.
-
_refreshPorts
protected void _refreshPorts()
Refresh the port lists scanning through the terms.
-
_refreshRank
protected void _refreshRank()
Recalculate the rank of the list as a term.
-
-