Class PrologList
- java.lang.Object
-
- com.igormaznitsa.prologparser.terms.PrologTerm
-
- com.igormaznitsa.prologparser.terms.PrologCompound
-
- com.igormaznitsa.prologparser.terms.PrologStruct
-
- com.igormaznitsa.prologparser.terms.PrologList
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<PrologTerm>,java.lang.Iterable<PrologTerm>
public final class PrologList extends PrologStruct implements java.lang.Iterable<PrologTerm>
Representation of prolog list term.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static PrologVarEMPTY_ANONYMOUS_VARstatic PrologTermLIST_FUNCTORprivate static longserialVersionUID-
Fields inherited from class com.igormaznitsa.prologparser.terms.PrologStruct
elements, EMPTY_ATOM, functor
-
Fields inherited from class com.igormaznitsa.prologparser.terms.PrologTerm
quotation, text
-
-
Constructor Summary
Constructors Constructor Description PrologList()PrologList(int line, int pos)PrologList(PrologTerm head)PrologList(PrologTerm[] array)PrologList(PrologTerm[] array, int line, int pos)PrologList(PrologTerm head, int line, int pos)PrologList(PrologTerm head, PrologTerm tail)PrologList(PrologTerm head, PrologTerm tail, int line, int pos)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PrologListaddAsNewListToEndOfListChain(PrologTerm term)Add term as new list into the end of the list chain.intgetArity()Arity of element.PrologTermgetHead()Get the current head element of the list.PrologTermgetTail()Get the current tail elementPrologTermgetTermAt(int index)Get element for its positionTermTypegetType()Get term type.booleanisEmpty()Check that the structure has elements.java.util.Iterator<PrologTerm>iterator()voidreplaceEndListElement(PrologTerm newTailElement)Replace last tail element in list chain.voidsetElementAt(int index, PrologTerm term)Set element for its position.voidsetHead(PrologTerm term)Replace the head element.voidsetTail(PrologTerm term)Set the current tail elementstatic PrologListsetTermAsNewListTail(PrologList list, PrologTerm term)java.util.stream.Stream<PrologTerm>stream()java.lang.StringtoString()-
Methods inherited from class com.igormaznitsa.prologparser.terms.PrologStruct
copyWithAnotherFunctor, flatComma, getFunctor, getPrecedence, isAnyBlock, isBlock, isCurlyBlock
-
Methods inherited from class com.igormaznitsa.prologparser.terms.PrologTerm
assertNonEmptyString, compareTo, findQuotation, getLine, getPos, getQuotation, getText, setLine, setPos
-
-
-
-
Field Detail
-
LIST_FUNCTOR
public static final PrologTerm LIST_FUNCTOR
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
EMPTY_ANONYMOUS_VAR
private static final PrologVar EMPTY_ANONYMOUS_VAR
-
-
Constructor Detail
-
PrologList
public PrologList()
-
PrologList
public PrologList(int line, int pos)
-
PrologList
public PrologList(PrologTerm[] array)
-
PrologList
public PrologList(PrologTerm[] array, int line, int pos)
-
PrologList
public PrologList(PrologTerm head)
-
PrologList
public PrologList(PrologTerm head, int line, int pos)
-
PrologList
public PrologList(PrologTerm head, PrologTerm tail)
-
PrologList
public PrologList(PrologTerm head, PrologTerm tail, int line, int pos)
-
-
Method Detail
-
setTermAsNewListTail
public static PrologList setTermAsNewListTail(PrologList list, PrologTerm term)
-
getTermAt
public PrologTerm getTermAt(int index)
Description copied from class:PrologCompoundGet element for its position- Overrides:
getTermAtin classPrologStruct- Parameters:
index- zero-based element position- Returns:
- element in position
-
isEmpty
public boolean isEmpty()
Description copied from class:PrologStructCheck that the structure has elements.- Overrides:
isEmptyin classPrologStruct- Returns:
- true if there is not elements, false otherwise
-
getHead
public PrologTerm getHead()
Get the current head element of the list.- Returns:
- the head element, can be null
-
setHead
public void setHead(PrologTerm term)
Replace the head element.- Parameters:
term- the new head term, can be null
-
getTail
public PrologTerm getTail()
Get the current tail element- Returns:
- the current tail element, can be null
-
setTail
public void setTail(PrologTerm term)
Set the current tail element- Parameters:
term- the new tail element, can be null
-
addAsNewListToEndOfListChain
public PrologList addAsNewListToEndOfListChain(PrologTerm term)
Add term as new list into the end of the list chain.- Parameters:
term- to be added as new list in the end of chain- Returns:
- generated list (may be this)
-
replaceEndListElement
public void replaceEndListElement(PrologTerm newTailElement)
Replace last tail element in list chain.- Parameters:
newTailElement- new element
-
getArity
public int getArity()
Description copied from class:PrologTermArity of element.- Overrides:
getArityin classPrologStruct- Returns:
- arity of element, make sense for compound terms, for primitive terms is 1
-
setElementAt
public void setElementAt(int index, PrologTerm term)Description copied from class:PrologStructSet element for its position.- Overrides:
setElementAtin classPrologStruct- Parameters:
index- zero based indexterm- term to set to position
-
getType
public TermType getType()
Description copied from class:PrologTermGet term type.- Overrides:
getTypein classPrologStruct- Returns:
- term type, must not be null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classPrologStruct
-
iterator
public java.util.Iterator<PrologTerm> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<PrologTerm>- Overrides:
iteratorin classPrologStruct
-
stream
public java.util.stream.Stream<PrologTerm> stream()
- Overrides:
streamin classPrologStruct
-
-