Class next.util.ImmutableVector

CLASS DESCRIPTION

Extends:
next.util.NextObject

Implements:
next/util/Coding

ImmutableVector declares the programmatic interface to an object that manages an unchanging array of objects. ImmutableVector's two primitive methods-size and elementAt-provide the basis for all other methods in its interface. The size method returns the number of elements in the array. elementAt gives you access to the array elements by index, with index values starting at 0.

The elements method also grants sequential access to the elements of the array. This method is provided so that arrays can be traversed in a manner similar to that used for objects of other collection classes such as ImmutableHashtable.

ImmutableVector provides methods for querying the elements of the array. indexOf searches the array for the object that matches its argument.

ImmutableVector's makeObjectsPerformMethod and makeObjectsPerformMethodWithObject methods let you send messages to all objects in the array.

You can compare two arrays using the firstObjectCommonWithArray method.


CONSTRUCTORS

ImmutableVector

public ImmutableVector()
public ImmutableVector(java.lang.Object[] objects)
public ImmutableVector(java.util.Vector aVector)

Initializes a newly allocated vector. After an immutable vector has been initialized, it can't be modified.

If objects are supplied, the vector is initialized by placing in it the objects contained in objects.

If aVector is supplied, the vector is initialized by placing in it the objects contained in the Java vector specified by aVector.


METHODS

capacity

public int capacity()

Returns the number of objects currently in the array.


contains

public boolean contains(java.lang.Object anObject)

Returns true if anObject is present in the vector.


copyInto

public void copyInto(java.lang.Object[] objects)

Copies the objects contained in the receiver to objects.


elementAt

public java.lang.Object elementAt(int index)

Returns the object located at index. If index is beyond the end of the vector (that is, if index is greater than or equal to the value returned by size), an exception is raised.


elements

public java.util.Enumeration elements()

Returns an enumerator object that lets you access each object in the vector, in order, starting with the element at index 0. When this method is used with mutable subclasses of ImmutableVector, your code shouldn't modify the vector during enumeration.


encodeWithCoder

public void encodeWithCoder(next.util.Coder aCoder)

Encodes the receiver using aCoder. See the Coding interface description for more information.


firstElement

public java.lang.Object firstElement()

Returns the object located at index 0.


firstObjectCommonWithArray

public java.lang.Object firstObjectCommonWithArray(next.util.ImmutableVector anImmutableVector)

Returns the first object contained in the receiver that's equal to an object in anImmutableVector. If no such object is found, this method returns nil.


indexOf

protected int indexOf(java.lang.Object start, int anInt, boolean forwards)

Searches the receiver for anObject and returns the lowest index whose corresponding vector value is equal to anObject. If none of the objects in the receiver are equal to anObject, indexOf returns -1. The vector is searched beginning with the object at index start. If forwards is true, the search proceeds towards the end of the vector; otherwise, it proceeds towards the beginning of the vector.


indexOf

public int indexOf(java.lang.Object anObject)
public int indexOf(java.lang.Object anObject, int start)

Searches the receiver for anObject and returns the lowest index whose corresponding vector value is equal to anObject. If none of the objects in the receiver are equal to anObject, indexOf returns -1.

If you specify start, the vector is searched beginning with the object at index start and proceeding to the end of the array.


initWithObjects

protected void initWithObjects(java.lang.Object[] objects)

Initializes a newly allocated array by placing in it the objects contained in objects. After an ImmutableVector has been initialized in this way, it can't be modified.


isEmpty

public boolean isEmpty()

Returns true if the vector contains no elements.


lastElement

public java.lang.Object lastElement()

Returns the object in the vector with the highest index value. If the vector is empty, lastElement returns nil.


lastIndexOf

public int lastIndexOf(java.lang.Object anObject)
public int lastIndexOf(java.lang.Object anObject, int start)

Searches the receiver for anObject and returns the highest index whose corresponding vector value is equal to anObject. If none of the objects in the receiver are equal to anObject, indexOf returns -1.

If you specify start, the vector is searched beginning with the object at index start and proceeding towards the beginning of the array.


makeObjectsPerformMethod

public void makeObjectsPerformMethod(java.lang.String aMethod)

Sends the aMethod message to each object in the vector in reverse order (starting with the last object and continuing backwards through the vector to the first object). The aMethod method must be one that takes no arguments. It shouldn't have the side effect of modifying the receiving vector.


makeObjectsPerformMethodWithObject

public void makeObjectsPerformMethodWithObject(java.lang.String aMethod, java.lang.Object anObject)

Sends the aMethod message to each object in the vector in reverse order (starting with the last object and continuing backwards through the vector to the first object). The message is sent each time with anObject as an argument, so the aMethod method must be one that takes a single argument of type java.lang.Object. The aMethod method shouldn't, as a side effect, modify the receiving vector.


size

public int size()

Returns the number of objects currently in the array.


vector

public java.util.Vector vector()

Returns a Java vector that contains each of the elements from the receiver.