jess
Class ValueVector

java.lang.Object
  extended byjess.ValueVector
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
Fact, Funcall

public class ValueVector
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A mini version of Vector (a self-extending array) that only holds Values. Not synchronized, so you must be careful of multithreading issues.

(C) E.J Friedman-Hill and Sandia National Laboratories

Author:
E.J. Friedman-Hill
See Also:
Serialized Form

Constructor Summary
ValueVector()
          Construct a ValueVector of the default size (10)
ValueVector(int size)
          Construct a ValueVector of the given size
 
Method Summary
 ValueVector add(Value val)
          Add a new element to the end of this ValueVector.
 ValueVector addAll(ValueVector vv)
          Append all Values.
 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)
          Comparethis valueVector to another object.
 Value get(int i)
          Fetch the entry at position i in thie 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 entry at position i to val.
 ValueVector setLength(int i)
          Set the length of this ValueVector.
 int size()
          Fetch 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
 

Constructor Detail

ValueVector

public ValueVector()
Construct a ValueVector of the default size (10)


ValueVector

public ValueVector(int size)
Construct a ValueVector of the given size

Parameters:
size - The number of Values this vector can hold at creation
Method Detail

size

public final int size()
Fetch the size of this ValueVector

Returns:
The size of this ValueVector

clone

public java.lang.Object clone()
Create a shallow copy of this ValueVector

Returns:
The copy

cloneInto

public ValueVector cloneInto(ValueVector vv)
Make the parameter into a copy of this ValueVector

Parameters:
vv - A ValueVector, whose contents are erased.
Returns:
The parameter

get

public Value get(int i)
          throws JessException
Fetch the entry at position i in thie ValueVector

Parameters:
i - The 0-based index of the Value to fetch
Returns:
The Value
Throws:
JessException

setLength

public ValueVector setLength(int i)
Set the length of this ValueVector. If necessary the storage will be extended.

Parameters:
i - The new length (>= 0)

set

public final ValueVector set(Value val,
                             int i)
                      throws JessException
Set the entry at position i to val. The argument must be >= 0 and < the return value of size().

Parameters:
val - The new value
i - The index at which to place it.
Throws:
JessException

add

public final ValueVector add(Value val)
Add a new element to the end of this ValueVector. The storage will be extended if necessary.

Parameters:
val - The value to add.

remove

public final ValueVector remove(int i)
                         throws JessException
Remove the item at index i from the ValueVector; move all the higher-numbered elements down.

Throws:
JessException

equals

public boolean equals(java.lang.Object o)
Comparethis valueVector to another object.

Parameters:
o - Another object
Returns:
True if the object is a valueVector of the same size containing Values that compare equal to the ones in this Vector.

copy

public static void copy(ValueVector src,
                        int srcPos,
                        ValueVector dest,
                        int destPos,
                        int length)
System.arraycopy DeLuxe for ValueVectors. Contributed by Thomas Barnekow


addAll

public ValueVector addAll(ValueVector vv)
Append all Values. Contributed by Thomas Barnekow


toString

public java.lang.String toString()
Return a String version of this ValueVector, without parentheses.

Returns:
The String

toStringWithParens

public java.lang.String toStringWithParens()
Return a String version of this ValueVector, with parentheses around all ValueVectors.

Returns:
The String

© 2001 E.J. Friedman-Hill and Sandia Corporation