Class 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)
    • 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 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.AbstractSequentialList

        iterator
      • Methods inherited from class java.util.AbstractList

        equals, hashCode, listIterator, removeRange, subList
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty, retainAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.util.Deque

        iterator
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        containsAll, equals, hashCode, isEmpty, iterator, listIterator, replaceAll, retainAll, sort, subList
    • Constructor Detail

      • SyntacticSeries

        public SyntacticSeries()
        Create an empty SyntacticSeries term.
    • 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 interface java.util.Collection<SyntacticTerm>
        Specified by:
        add in interface java.util.Deque<SyntacticTerm>
        Specified by:
        add in interface java.util.List<SyntacticTerm>
        Specified by:
        add in interface java.util.Queue<SyntacticTerm>
        Overrides:
        add in class SyntacticTermList
        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 interface java.util.Deque<SyntacticTerm>
        Overrides:
        push in class java.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 interface java.util.List<SyntacticTerm>
        Overrides:
        add in class SyntacticTermList
        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 interface SyntacticTerm
        Overrides:
        generateCode in class SyntacticTermList
        Returns:
        code for term.