Package jason.asSyntax
Class ListTermImpl
java.lang.Object
jason.asSyntax.DefaultTerm
jason.asSyntax.Literal
jason.asSyntax.Atom
jason.asSyntax.Structure
jason.asSyntax.ListTermImpl
- All Implemented Interfaces:
ListTerm
,LogicalFormula
,Term
,ToDOM
,ToJson
,Serializable
,Cloneable
,Comparable<Term>
,Iterable<Term>
,Collection<Term>
,List<Term>
,SequencedCollection<Term>
Represents a list node as in prolog .(t1,.(t2,.(t3,.))).
Each nth-ListTerm has both a term and the next ListTerm.
The last ListTem is an empty ListTerm (term==null).
In lists terms with a tail ([a|X]), next is the Tail (next==X, term==a).
- See Also:
-
Field Summary
Fields inherited from class jason.asSyntax.Structure
emptyTermArray, emptyTermList
Fields inherited from class jason.asSyntax.Literal
DefaultNS, LFalse, LNeg, LPos, LTrue, predicateIndicatorCache
Fields inherited from class jason.asSyntax.DefaultTerm
hashCodeCache, srcInfo
Fields inherited from interface jason.asSyntax.ListTerm
EMPTY_LIST
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection c) boolean
addAll
(Collection c) void
Adds a term in the end of the listint
make a hard copy of the termsvoid
clear()
clone()
make a hard copy of the termscloneLT()
make a hard copy of the termsmake a shallow copy of the list (terms are not cloned, only the structure)int
Adds a list in the end of this list.boolean
boolean
difference
(ListTerm lt) returns a new (cloned) list representing the set resulting of the difference of this list and lt.boolean
get
(int index) int
getArity()
returns the number of terms of this literalget as XMLjavax.json.JsonValue
Returns this ListTerm as a Java List (implemented by ArrayList).getLast()
get the last ListTerm of this ListgetNext()
getTail()
returns this ListTerm's tail element in case the List has the Tail, otherwise, returns nullgetTerm()
gets the term of this ListTermgetTerm
(int i) returns the i-th term (first term is 0)getTerms()
return the this ListTerm elements (0=Term, 1=ListTerm)int
insert a term in the begin of this listintersection
(ListTerm lt) returns a new (cloned) list representing the set resulting of the intersection of this list and lt.boolean
isAtom()
boolean
isEmpty()
boolean
isEnd()
boolean
isGround()
boolean
isList()
boolean
boolean
isTail()
iterator()
returns an iterator where each element is a Term of this list, the tail of the list is not considered.int
lastIndexOf
(Object arg0) listIterator
(int startIndex) gives an iterator that includes the final empty list or tail, for [a,b,c] returns [a,b,c]; [b,c]; [c]; and [].logicalConsequence
(Agent ag, Unifier un) logicalConsequence checks whether one particular predicate is a logical consequence of the belief base.static ListTerm
remove
(int index) boolean
boolean
boolean
reverse()
Creates a new (cloned) list with the same elements of this list, but in the reversed order.void
void
set the tail of this listvoid
void
protected void
int
size()
subList
(int arg0, int arg1) subSets
(int k) returns all subsets that take k elements of this listObject[]
toArray()
<T> T[]
toArray
(T[] a) toString()
returns a new (cloned) list representing the set resulting of the union of this list and lt.Methods inherited from class jason.asSyntax.Structure
addTerms, addTerms, cloneNS, countVars, delTerm, getSingletonVars, getTermsSize, hasTerm, hasVar, isStructure, isUnary, makeTermsAnnon, makeVarsAnnon, makeVarsAnnon, parse, setTerms, subsumes, varToReplace
Methods inherited from class jason.asSyntax.Atom
getFunctor, getNS
Methods inherited from class jason.asSyntax.Literal
addAnnot, addAnnots, addAnnots, addSource, addSourceInfoAsAnnots, canBeAddedInBB, clearAnnots, copy, delAnnot, delAnnots, delAnnots, delSource, delSources, equalsAsStructure, forceFullLiteralImpl, getAnnot, getAnnots, getAnnots, getAsListOfTerms, getPredicateIndicator, getSources, getTermsArray, hasAnnot, hasAnnot, hasSource, hasSource, hasSubsetAnnot, hasSubsetAnnot, importAnnots, negated, newFromListOfTerms, newFunctor, noSource, parseLiteral, setAnnots, setNegated, subjectToBUF
Methods inherited from class jason.asSyntax.DefaultTerm
getCyclicVar, getErrorMsg, getSrcInfo, hashCode, isArithExpr, isCyclicTerm, isInternalAction, isMap, isNumeric, isPlanBody, isPred, isRule, isSet, isString, isUnnamedVar, isVar, resetHashCodeCache, setSrcInfo
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.List
addFirst, addLast, getFirst, hashCode, removeFirst, replaceAll, reversed, sort, spliterator
Methods inherited from interface jason.asSyntax.Term
cloneNS, countVars, getCyclicVar, getSrcInfo, hasVar, isArithExpr, isCyclicTerm, isInternalAction, isMap, isNumeric, isPlanBody, isPred, isRule, isSet, isString, isStructure, isUnnamedVar, isVar, setSrcInfo, subsumes
Methods inherited from interface jason.util.ToJson
getAsJsonStr
-
Field Details
-
LIST_FUNCTOR
- See Also:
-
-
Constructor Details
-
ListTermImpl
public ListTermImpl()
-
-
Method Details
-
parseList
-
clone
make a hard copy of the terms -
cloneLT
make a hard copy of the terms -
capply
make a hard copy of the terms -
cloneLTShallow
make a shallow copy of the list (terms are not cloned, only the structure)- Specified by:
cloneLTShallow
in interfaceListTerm
-
equals
-
calcHashCode
public int calcHashCode()- Overrides:
calcHashCode
in classStructure
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Term>
- Overrides:
compareTo
in classAtom
-
setTerm
-
getTerm
gets the term of this ListTerm -
setNext
-
getNext
-
getArity
public int getArity()Description copied from class:Literal
returns the number of terms of this literal -
getTerm
Description copied from class:Literal
returns the i-th term (first term is 0) -
setTerm
-
getTerms
return the this ListTerm elements (0=Term, 1=ListTerm) -
addTerm
-
size
public int size() -
isAtom
public boolean isAtom() -
isList
public boolean isList()- Specified by:
isList
in interfaceTerm
- Overrides:
isList
in classDefaultTerm
-
isLiteral
public boolean isLiteral() -
isEmpty
public boolean isEmpty() -
isEnd
public boolean isEnd() -
isGround
public boolean isGround() -
logicalConsequence
Description copied from class:Literal
logicalConsequence checks whether one particular predicate is a logical consequence of the belief base. Returns an iterator for all unifiers that are logCons.- Specified by:
logicalConsequence
in interfaceLogicalFormula
- Overrides:
logicalConsequence
in classLiteral
-
isTail
public boolean isTail() -
getTail
returns this ListTerm's tail element in case the List has the Tail, otherwise, returns null -
setTail
set the tail of this list -
getLast
get the last ListTerm of this List -
getPenultimate
- Specified by:
getPenultimate
in interfaceListTerm
-
removeLast
- Specified by:
removeLast
in interfaceList<Term>
- Specified by:
removeLast
in interfaceListTerm
- Specified by:
removeLast
in interfaceSequencedCollection<Term>
-
append
Adds a term in the end of the list -
insert
insert a term in the begin of this list -
concat
Adds a list in the end of this list. This method do not clone lt. -
reverse
Creates a new (cloned) list with the same elements of this list, but in the reversed order. The Tail remains the Tail: reverse([a,b|T]) = [b,a|T]. -
union
returns a new (cloned) list representing the set resulting of the union of this list and lt. -
intersection
returns a new (cloned) list representing the set resulting of the intersection of this list and lt.- Specified by:
intersection
in interfaceListTerm
-
difference
returns a new (cloned) list representing the set resulting of the difference of this list and lt.- Specified by:
difference
in interfaceListTerm
-
subSets
returns all subsets that take k elements of this list -
listTermIterator
gives an iterator that includes the final empty list or tail, for [a,b,c] returns [a,b,c]; [b,c]; [c]; and []. for [a,b|T] returns [a,b|T]; [b|T]; [b|T]; and T.- Specified by:
listTermIterator
in interfaceListTerm
-
iterator
returns an iterator where each element is a Term of this list, the tail of the list is not considered. for [a,b,c] returns 'a', 'b', and 'c'. for [a,b|T] returns 'a' and 'b'. -
getAsList
Returns this ListTerm as a Java List (implemented by ArrayList). Note: the tail of the list, if any, is not included! -
toString
-
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAll
in interfaceCollection<Term>
- Specified by:
containsAll
in interfaceList<Term>
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<Term>
-
listIterator
- Specified by:
listIterator
in interfaceList<Term>
-
listIterator
- Specified by:
listIterator
in interfaceList<Term>
-
setValuesFrom
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
getAsDOM
Description copied from class:Structure
get as XML -
getAsJson
public javax.json.JsonValue getAsJson()
-