|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jess.ValueVector
A self-extending array that only holds Value
objects.
The ValueVector class is Jess's internal representation
of a Lisp list, and therefore has a central role in programming with
Jess in Java. The ValueVector class itself is used to
represent generic lists, while specialized subclasses
are used as function calls (Funcall
and facts
(Fact
).
ValueVector vv = new ValueVector(); vv.add("a"); vv.add("b"); vv.add("c"); // Prints "(a b c)" System.out.println(vv.toStringWithParens());To pass a ValueVector from Java to Jess, you should enclose it in a
Value
object of type RU.LIST
.
Value myList = new Value(vv, RU.LIST);ValueVector is not synchronized, so you must be careful of multithreading issues.
(C) 2005 Sandia National Laboratories
Value
,
Serialized FormField Summary | |
protected int |
m_ptr
The current number of elements. |
protected Value[] |
m_v
The elements themselves. |
Constructor Summary | |
ValueVector()
Construct a ValueVector of the default capacity (10). |
|
ValueVector(int size)
Construct a ValueVector of the given capacity. |
Method Summary | |
ValueVector |
add(boolean val)
Add a new element to the end of this ValueVector. |
ValueVector |
add(double val)
Add a new element to the end of this ValueVector. |
ValueVector |
add(int val)
Add a new element to the end of this ValueVector. |
ValueVector |
add(long val)
Add a new element to the end of this ValueVector. |
ValueVector |
add(java.lang.Object val)
Add a new element to the end of this ValueVector. |
ValueVector |
add(java.lang.String val)
Add a new element to the end of this ValueVector. |
ValueVector |
add(Value val)
Add a new element to the end of this ValueVector. |
void |
addAll(java.util.Collection list)
Add all the members of the collection to this ValueVector. |
ValueVector |
addAll(ValueVector vv)
Appends all Values in the argument ValueVector. |
java.lang.Object |
clone()
Create a shallow copy of this ValueVector. |
ValueVector |
cloneInto(ValueVector vv)
Make the parameter into a copy of this ValueVector. |
static void |
copy(ValueVector src,
int srcPos,
ValueVector dest,
int destPos,
int length)
System.arraycopy DeLuxe for ValueVectors. |
boolean |
equals(java.lang.Object o)
Compare this ValueVector to another object. |
Value |
get(int i)
Returns the entry at position i in this ValueVector. |
ValueVector |
remove(int i)
Remove the item at index i from the ValueVector; move all the higher-numbered elements down. |
ValueVector |
set(Value val,
int i)
Set the element at position i to the given value. |
ValueVector |
setLength(int i)
Set the length of this ValueVector. |
int |
size()
Returns the size of this ValueVector. |
java.lang.String |
toString()
Return a String version of this ValueVector, without parentheses. |
java.lang.String |
toStringWithParens()
Return a String version of this ValueVector, with parentheses around all ValueVectors. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Value[] m_v
protected int m_ptr
Constructor Detail |
public ValueVector()
public ValueVector(int size)
size
- The number of Values this vector can hold at creationMethod Detail |
public final int size()
public java.lang.Object clone()
public ValueVector cloneInto(ValueVector vv)
vv
- a ValueVector, whose contents are erased.
public Value get(int i) throws JessException
i
- the 0-based index of the Value to fetch
JessException
public ValueVector setLength(int i)
i
- The new length (>= 0)
public final ValueVector set(Value val, int i) throws JessException
val
- the new valuei
- the index at which to place it.
JessException
public final ValueVector add(Value val)
ValueVector vv = new ValueVector(); vv.add(new Value("a", RU.SYMBOL)).add(new Value("b", RU.SYMBOL)).add(new Value("c", RU.SYMBOL)); // Prints "(a b c)" System.out.println(vv.toStringWithParens());
val
- the value to add.
public final ValueVector add(java.lang.String val) throws JessException
val
- the value to add, interpreted as a symbol
JessException
add(Value)
public final ValueVector add(int val) throws JessException
val
- the value to add, interpreted as an RU.INTEGER
JessException
add(Value)
public final ValueVector add(double val) throws JessException
val
- the value to add, interpreted as an RU.FLOAT
JessException
add(Value)
public final ValueVector add(boolean val)
val
- the value to add; will become one of the symbols TRUE or FALSE
add(Value)
public final ValueVector add(long val) throws JessException
val
- the value to add, as an RU.LONG
JessException
add(Value)
public final ValueVector add(java.lang.Object val)
val
- the value to add, as an RU.JAVA_OBJECT
add(Value)
public final ValueVector remove(int i) throws JessException
JessException
public boolean equals(java.lang.Object o)
o
- another object
public static void copy(ValueVector src, int srcPos, ValueVector dest, int destPos, int length)
src
- the ValueVector to copy fromsrcPos
- the index to copy frmodest
- the ValueVector to copy todestPos
- the index to copy tolength
- the number of elements to copypublic ValueVector addAll(ValueVector vv)
vv
- a ValueVector to copy elements from.public java.lang.String toString()
public java.lang.String toStringWithParens()
public void addAll(java.util.Collection list)
Value
s.
list
- a collection of jess.Value objects
java.lang.ClassCastException
- if any of the members of the collection are not jess.Value objects
|
© 2006 Sandia Corporation | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |