ilog.views
Class IlvGraphicVector

java.lang.Object
  extended by ilog.views.IlvGraphicVector
All Implemented Interfaces:
Serializable, Cloneable

public class IlvGraphicVector
extends Object
implements Cloneable, Serializable

An IlvGraphicVector is an expandable array of graphic objects. Note that the implementation is not synchronized. If multiple threads access an IlvGraphicVector concurrently, and at least one of the threads modifies the list structurally, it must be synchronized externally.

See Also:
Serialized Form

Field Summary
protected  int capacityIncrement
          The size of the increment.
protected  int elementCount
          The number of elements in the buffer.
protected  IlvGraphic[] elementData
          The buffer in which elements are stored.
 
Constructor Summary
IlvGraphicVector()
          Constructs an empty vector.
IlvGraphicVector(int initialCapacity)
          Constructs an empty vector with the specified storage capacity.
IlvGraphicVector(int initialCapacity, int capacityIncrement)
          Constructs an empty vector with the specified storage capacity and the specified capacityIncrement.
 
Method Summary
 void addElement(IlvGraphic obj)
          Adds the specified object as the last element of the vector.
 int capacity()
          Returns the current capacity of the vector.
 Object clone()
          Clones this vector.
 boolean contains(IlvGraphic elem)
          Returns true if the specified element is a value of the vector.
 void copyInto(IlvGraphic[] anArray)
          Copies the elements of this vector into the specified array.
 IlvGraphic elementAt(int index)
          Returns the element at the specified index.
 IlvGraphicEnumeration elements()
          Returns an enumeration of the elements.
 void ensureCapacity(int minCapacity)
          Ensures that the vector has at least the specified capacity.
 IlvGraphic firstElement()
          Returns the first element of the sequence.
 int indexOf(IlvGraphic elem)
          Searches for the specified element starting from the first position.
 int indexOf(IlvGraphic elem, int index)
          Searches for the specified element starting from the specified position.
 void insertElementAt(IlvGraphic obj, int index)
          Inserts the specified object as an element at the specified index.
 boolean isEmpty()
          Returns true if the vector contains no values.
 IlvGraphic lastElement()
          Returns the last element of the sequence.
 int lastIndexOf(IlvGraphic elem)
          Searches backwards for the specified element, starting from the last position.
 int lastIndexOf(IlvGraphic elem, int index)
          Searches backwards for the specified element, starting from the specified position.
 void removeAllElements()
          Removes all elements of the vector.
 boolean removeElement(IlvGraphic obj)
          Removes the element from the vector.
 void removeElementAt(int index)
          Deletes the element at the specified index.
 IlvGraphic setElementAt(IlvGraphic obj, int index)
          Sets the element at the specified index to be the specified object.
 void setSize(int newSize)
          Sets the size of the vector.
 int size()
          Returns the number of elements in the vector.
 String toString()
          Converts the vector to a string.
 void trimToSize()
          Optimizes the capacity of the vector.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elementData

protected IlvGraphic[] elementData
The buffer in which elements are stored.


elementCount

protected int elementCount
The number of elements in the buffer.


capacityIncrement

protected int capacityIncrement
The size of the increment. If it is 0, the size of the buffer is doubled each time it needs to grow.

Constructor Detail

IlvGraphicVector

public IlvGraphicVector(int initialCapacity,
                        int capacityIncrement)
Constructs an empty vector with the specified storage capacity and the specified capacityIncrement.

Parameters:
initialCapacity - the initial storage capacity of the vector.
capacityIncrement - how much to increase the size of the element by.

IlvGraphicVector

public IlvGraphicVector(int initialCapacity)
Constructs an empty vector with the specified storage capacity.

Parameters:
initialCapacity - the initial storage capacity of the vector.

IlvGraphicVector

public IlvGraphicVector()
Constructs an empty vector.

Method Detail

copyInto

public final void copyInto(IlvGraphic[] anArray)
Copies the elements of this vector into the specified array.

Parameters:
anArray - the array which elements are copied into.

trimToSize

public final void trimToSize()
Optimizes the capacity of the vector. Use this operation to minimize the storage of a vector. Subsequent insertions will cause reallocation.


ensureCapacity

public final void ensureCapacity(int minCapacity)
Ensures that the vector has at least the specified capacity.

Parameters:
minCapacity - the desired minimum capacity.

setSize

public final void setSize(int newSize)
Sets the size of the vector. If the size shrinks, the extra elements (at the end of the vector) are lost. Whereas, if the size increases the new elements are set to null.

Parameters:
newSize - the new vector size.

capacity

public final int capacity()
Returns the current capacity of the vector.


size

public final int size()
Returns the number of elements in the vector. Note that this is not the same as the capacity of the vector.


isEmpty

public final boolean isEmpty()
Returns true if the vector contains no values.


elements

public final IlvGraphicEnumeration elements()
Returns an enumeration of the elements. Use the Enumeration methods on the returned object to fetch the elements sequentially.


contains

public final boolean contains(IlvGraphic elem)
Returns true if the specified element is a value of the vector.

Parameters:
elem - the desired element.

indexOf

public final int indexOf(IlvGraphic elem)
Searches for the specified element starting from the first position. It returns an index to it.

Parameters:
elem - the desired element.
Returns:
the index of the element, or -1 if it is not found.

indexOf

public final int indexOf(IlvGraphic elem,
                         int index)
Searches for the specified element starting from the specified position. It returns the element index.

Parameters:
elem - the desired element.
index - the index where the search should be started.
Returns:
the index of the element, or -1 if it is not found.

lastIndexOf

public final int lastIndexOf(IlvGraphic elem)
Searches backwards for the specified element, starting from the last position. It returns the element index.

Parameters:
elem - the desired element.
Returns:
the index of the element, or -1 if it is not found.

lastIndexOf

public final int lastIndexOf(IlvGraphic elem,
                             int index)
Searches backwards for the specified element, starting from the specified position. It returns an index to the element.

Parameters:
elem - the desired element.
index - the index where the search should be started.
Returns:
the index of the element, or -1 if it is not found.

elementAt

public final IlvGraphic elementAt(int index)
Returns the element at the specified index.

Parameters:
index - the index of the desired element.
Throws:
ArrayIndexOutOfBoundsException - if the index supplied was not valid.

firstElement

public final IlvGraphic firstElement()
Returns the first element of the sequence.

Throws:
NoSuchElementException - if the sequence is empty.

lastElement

public final IlvGraphic lastElement()
Returns the last element of the sequence.

Throws:
NoSuchElementException - if the sequence is empty.

setElementAt

public final IlvGraphic setElementAt(IlvGraphic obj,
                                     int index)
Sets the element at the specified index to be the specified object. The previous element at that position is returned.

Parameters:
obj - what the element is to be set to.
index - the specified index.
Throws:
ArrayIndexOutOfBoundsException - if the index was not valid.

removeElementAt

public final void removeElementAt(int index)
Deletes the element at the specified index. Elements with an index greater than the current index are moved down.

Parameters:
index - the element to be removed.
Throws:
ArrayIndexOutOfBoundsException - if the index was not valid.

insertElementAt

public final void insertElementAt(IlvGraphic obj,
                                  int index)
Inserts the specified object as an element at the specified index. Elements with an index greater or equal to the current index are shifted up.

Parameters:
obj - the element to be inserted.
index - where the new element should be inserted.
Throws:
ArrayIndexOutOfBoundsException - if the index was not valid.

addElement

public final void addElement(IlvGraphic obj)
Adds the specified object as the last element of the vector.

Parameters:
obj - the element to be added.

removeElement

public final boolean removeElement(IlvGraphic obj)
Removes the element from the vector. If the object occurs more than once, only the first occurrence is removed. If the object is not an element this method returns false.

Parameters:
obj - the element to be removed
Returns:
true if the element was successfully removed. Otherwise it returns false.

removeAllElements

public final void removeAllElements()
Removes all elements of the vector. The vector becomes empty.


clone

public Object clone()
Clones this vector. The elements are not cloned.

Overrides:
clone in class Object

toString

public final String toString()
Converts the vector to a string. This is useful for debugging.

Overrides:
toString in class Object


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.