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:
Serializable,Comparable<PrologTerm>,Iterable<PrologTerm>
Representation of prolog list term.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PrologVarstatic final PrologTermprivate static final longFields inherited from class com.igormaznitsa.prologparser.terms.PrologStruct
elements, EMPTY_ATOM, functorFields inherited from class com.igormaznitsa.prologparser.terms.PrologTerm
quotation, text -
Constructor Summary
ConstructorsConstructorDescriptionPrologList(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
Modifier and TypeMethodDescriptionAdd term as new list into the end of the list chain.intgetArity()Arity of element.getHead()Get the current head element of the list.getTail()Get the current tail elementgetTermAt(int index) Get element for its positiongetType()Get term type.booleanisEmpty()Check that the structure has elements.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) stream()toString()Methods inherited from class com.igormaznitsa.prologparser.terms.PrologStruct
copyWithAnotherFunctor, flatComma, getFunctor, getPrecedence, isAnyBlock, isBlock, isCurlyBlockMethods inherited from class com.igormaznitsa.prologparser.terms.PrologTerm
assertNonEmptyString, compareTo, findQuotation, getLine, getPos, getQuotation, getText, setLine, setPosMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
LIST_FUNCTOR
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
EMPTY_ANONYMOUS_VAR
-
-
Constructor Details
-
PrologList
public PrologList() -
PrologList
public PrologList(int line, int pos) -
PrologList
-
PrologList
-
PrologList
-
PrologList
-
PrologList
-
PrologList
-
-
Method Details
-
setTermAsNewListTail
-
getTermAt
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
Get the current head element of the list.- Returns:
- the head element, can be null
-
setHead
Replace the head element.- Parameters:
term- the new head term, can be null
-
getTail
Get the current tail element- Returns:
- the current tail element, can be null
-
setTail
Set the current tail element- Parameters:
term- the new tail element, can be null
-
addAsNewListToEndOfListChain
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
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
Description copied from class:PrologStructSet element for its position.- Overrides:
setElementAtin classPrologStruct- Parameters:
index- zero based indexterm- term to set to position
-
getType
Description copied from class:PrologTermGet term type.- Overrides:
getTypein classPrologStruct- Returns:
- term type, must not be null
-
toString
- Overrides:
toStringin classPrologStruct
-
iterator
- Specified by:
iteratorin interfaceIterable<PrologTerm>- Overrides:
iteratorin classPrologStruct
-
stream
- Overrides:
streamin classPrologStruct
-