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
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<Term>
,java.lang.Iterable<Term>
,java.util.Collection<Term>
,java.util.List<Term>
public class ListTermImpl extends Structure implements ListTerm
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).
- Author:
- Jomi
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ListTermImpl.ListTermIterator<T>
Nested classes/interfaces inherited from class jason.asSyntax.Literal
Literal.FalseLiteral, Literal.TrueLiteral
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LIST_FUNCTOR
private static java.util.logging.Logger
logger
private Term
next
private static long
serialVersionUID
private Term
term
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
Constructors Modifier Constructor Description ListTermImpl()
private
ListTermImpl(Term t, Term n)
-
Method Summary
Modifier and Type Method Description void
add(int index, Term o)
boolean
add(Term o)
boolean
addAll(int index, java.util.Collection c)
boolean
addAll(java.util.Collection c)
void
addTerm(Term t)
ListTerm
append(Term t)
Adds a term in the end of the listint
calcHashCode()
ListTerm
capply(Unifier u)
make a hard copy of the termsvoid
clear()
ListTerm
clone()
make a hard copy of the termsListTerm
cloneLT()
make a hard copy of the termsListTerm
cloneLTShallow()
make a shallow copy of the list (terms are not cloned, only the structure)int
compareTo(Term o)
ListTerm
concat(ListTerm lt)
Adds a list in the end of this list.boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection c)
ListTerm
difference(ListTerm lt)
returns a new (cloned) list representing the set resulting of the difference of this list and lt.boolean
equals(java.lang.Object t)
Term
get(int index)
int
getArity()
returns the number of terms of this literalorg.w3c.dom.Element
getAsDOM(org.w3c.dom.Document document)
get as XMLjavax.json.JsonValue
getAsJson()
java.util.List<Term>
getAsList()
Returns this ListTerm as a Java List (implemented by ArrayList).ListTerm
getLast()
get the last ListTerm of this ListListTerm
getNext()
ListTerm
getPenultimate()
VarTerm
getTail()
returns this ListTerm's tail element in case the List has the Tail, otherwise, returns nullTerm
getTerm()
gets the term of this ListTermTerm
getTerm(int i)
returns the i-th term (first term is 0)java.util.List<Term>
getTerms()
return the this ListTerm elements (0=Term, 1=ListTerm)int
indexOf(java.lang.Object o)
ListTerm
insert(Term t)
insert a term in the begin of this listListTerm
intersection(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
isLiteral()
boolean
isTail()
java.util.Iterator<Term>
iterator()
returns an iterator where each element is a Term of this list, the tail of the list is not considered.int
lastIndexOf(java.lang.Object arg0)
java.util.ListIterator<Term>
listIterator()
java.util.ListIterator<Term>
listIterator(int startIndex)
java.util.Iterator<ListTerm>
listTermIterator()
gives an iterator that includes the final empty list or tail, for [a,b,c] returns [a,b,c]; [b,c]; [c]; and [].java.util.Iterator<Unifier>
logicalConsequence(Agent ag, Unifier un)
logicalConsequence checks whether one particular predicate is a logical consequence of the belief base.static ListTerm
parseList(java.lang.String sList)
Term
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection c)
Term
removeLast()
boolean
retainAll(java.util.Collection c)
ListTerm
reverse()
Creates a new (cloned) list with the same elements of this list, but in the reversed order.private ListTerm
reverse_internal(ListTerm r)
Term
set(int index, Term t)
void
setNext(Term l)
void
setTail(VarTerm v)
set the tail of this listvoid
setTerm(int i, Term t)
void
setTerm(Term t)
private ListTerm
setToList(java.util.Set<Term> set)
protected void
setValuesFrom(ListTerm lt)
int
size()
java.util.List<Term>
subList(int arg0, int arg1)
java.util.Iterator<java.util.List<Term>>
subSets(int k)
returns all subsets that take k elements of this listjava.lang.Object[]
toArray()
<T> T[]
toArray(T[] a)
java.lang.String
toString()
ListTerm
union(ListTerm lt)
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.lang.Iterable
forEach
Methods inherited from interface java.util.List
hashCode, replaceAll, 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
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
logger
private static java.util.logging.Logger logger -
LIST_FUNCTOR
public static final java.lang.String LIST_FUNCTOR- See Also:
- Constant Field Values
-
term
-
next
-
-
Constructor Details
-
ListTermImpl
public ListTermImpl() -
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
public boolean equals(java.lang.Object t) -
calcHashCode
public int calcHashCode()- Overrides:
calcHashCode
in classStructure
-
compareTo
-
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 interfaceListTerm
-
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]. -
reverse_internal
-
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
-
setToList
-
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
public java.lang.String toString() -
add
- Specified by:
add
in interfacejava.util.List<Term>
-
add
-
addAll
public boolean addAll(java.util.Collection c) -
addAll
public boolean addAll(int index, java.util.Collection c)- Specified by:
addAll
in interfacejava.util.List<Term>
-
clear
public void clear() -
contains
public boolean contains(java.lang.Object o) -
containsAll
public boolean containsAll(java.util.Collection c) -
get
- Specified by:
get
in interfacejava.util.List<Term>
-
indexOf
public int indexOf(java.lang.Object o)- Specified by:
indexOf
in interfacejava.util.List<Term>
-
lastIndexOf
public int lastIndexOf(java.lang.Object arg0)- Specified by:
lastIndexOf
in interfacejava.util.List<Term>
-
listIterator
- Specified by:
listIterator
in interfacejava.util.List<Term>
-
listIterator
- Specified by:
listIterator
in interfacejava.util.List<Term>
-
setValuesFrom
-
remove
- Specified by:
remove
in interfacejava.util.List<Term>
-
remove
public boolean remove(java.lang.Object o) -
removeAll
public boolean removeAll(java.util.Collection c) -
retainAll
public boolean retainAll(java.util.Collection c) -
set
- Specified by:
set
in interfacejava.util.List<Term>
-
subList
- Specified by:
subList
in interfacejava.util.List<Term>
-
toArray
public java.lang.Object[] toArray() -
toArray
public <T> T[] toArray(T[] a) -
getAsDOM
public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)Description copied from class:Structure
get as XML -
getAsJson
public javax.json.JsonValue getAsJson()
-