|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--CiaoJava.PLTerm | +--CiaoJava.PLList
Java representation of a Prolog list. Contains a representation
of a Prolog list using the same head/tail structure of the Prolog lists
The last element of the list must be an empty list.
The empty list must be referred as the PLTerm.nil
static
field, due to the serialization mechanism of Prolog terms, that
represents the empty list as an atom, not a list.
Field Summary | |
private PLTerm |
Head
|
private int |
INCREMENT
|
private int |
START_CAPACITY
|
private PLTerm |
Tail
|
Constructor Summary | |
PLList(PLTerm[] list)
Given a Java list, creates a Java PLList object containing the objects included in the Java list. |
|
PLList(PLTerm h,
PLTerm t)
Given a head and a tail, creates a Java PLList object. |
|
PLList(java.lang.String s)
Given a Java string, creates a Java PLList object containing the characters included in the Java string. |
Method Summary | |
void |
add(PLTerm term)
Adds a term at the tail of a PLList object. |
void |
backtrack(PLTerm term)
|
PLTerm |
copy()
Makes a full copy of this PLList Prolog list
object. |
boolean |
equals(PLTerm t)
Compares the PLList object with the PLTerm given as argument. |
PLTerm |
getHead()
Gets the head of a PLList object. |
PLTerm |
getTail()
Gets the tail of a PLList object. |
boolean |
isRunnable()
Execution test on Prolog objects. |
java.lang.Object |
javaRepr(PLInterpreter i)
Java representation of a PLList. |
int |
length()
Returns the number of elements of this PLList . |
protected int |
numberOfCells()
Returns the number of cells needed to represent this PLList in the Prolog heap. |
protected void |
setTail(PLList l)
Sets the tail of a PLList object, removing the previous tail. |
java.lang.String |
toString()
String representation of a Java PLList object. |
boolean |
unify(PLTerm term)
Term unification. |
Methods inherited from class CiaoJava.PLTerm |
fastRead,
fastWrite,
genPrefix,
genTerm,
getChar,
getFloat,
getInt,
getPrefix,
getString,
getTerm,
isException,
isList,
isNil,
isPrologFail,
isPrologSuccess,
isQueryId,
isSolution,
isString,
isStructure,
isVariable,
launchGoal |
Methods inherited from class java.lang.Object |
|
Field Detail |
private PLTerm Head
private PLTerm Tail
private final int START_CAPACITY
private final int INCREMENT
Constructor Detail |
public PLList(PLTerm h, PLTerm t)
PLList
.h
- First element of the list. Can be any Prolog term.t
- Rest of the list. Must be nil (if the list contains
just one element), or another PLList
object.public PLList(PLTerm[] list)
list
- Java list that contains the elements that must be
included in the Prolog list.public PLList(java.lang.String s)
s
- Java string that contains the characters that must be
included in the Prolog list as elements.Method Detail |
public java.lang.String toString()
public java.lang.Object javaRepr(PLInterpreter i)
i
- PLInterpreter
object used to do
the interpretation. Included here only for
compatibility purposes with the PLTerm
abstract class.Object
array.public boolean isRunnable()
PLTerm
class.false
.public PLTerm getHead()
public PLTerm getTail()
protected void setTail(PLList l)
l
- PLList
object that represents the new
tail.public void add(PLTerm term)
term
- Prolog term to be added at the end of this list.public boolean equals(PLTerm t)
t
- Prolog term to be compared to.true
if this term is equal to
the term received as argument;
false
otherwise.public PLTerm copy()
PLList
Prolog list
object. Recursively clones the elements of this term, in order to
return a separated copy of all the elements included
in this list.PLTerm
object that is a full
copy of this list. All the elements of this list
are copied in turn.public boolean unify(PLTerm term)
term
- Term to unify with.true
if the unification is successful;
false
otherwise.public void backtrack(PLTerm term) throws PLException
public int length()
PLList
.protected int numberOfCells()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |