| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjess.ValueVector
A self-extending array that only holds Value objects.
 
Funcall and facts
 (Fact).
 
 Working with ValueVector itself is simple. Its API is
 similar to the List interface.
 ValueVector is a self-extending array: when new elements are added, the
 ValueVector grows in size to accomodate them. Here is a bit
 of example Java code in which we create the Jess list
 (a b c).
 
 
 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) 2006 Sandia National Laboratories
Value, 
Serialized Form| Field Summary | |
| protected  int | m_ptrThe current number of elements. | 
| protected  Value[] | m_vThe 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. | 
|  int | hashCode()Returns the sum of the hashcodes of the members. | 
|  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, 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 creation| Method 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
JessExceptionpublic 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.
JessExceptionpublic 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
JessExceptionadd(Value)
public final ValueVector add(int val)
                      throws JessException
val - the value to add, interpreted as an RU.INTEGER
JessExceptionadd(Value)
public final ValueVector add(double val)
                      throws JessException
val - the value to add, interpreted as an RU.FLOAT
JessExceptionadd(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
JessExceptionadd(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
JessExceptionpublic 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)
Values.
list - a collection of jess.Value objects
java.lang.ClassCastException - if any of the members of the collection are not jess.Value objectspublic int hashCode()
| 
 | © 2007 Sandia Corporation | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||