org.piratis.j2me.core
Class QuickList

java.lang.Object
  extended byorg.piratis.j2me.core.QuickList

public class QuickList
extends java.lang.Object

Provides a QuickList (Vector/ArrayList) implementation

Version:
$Id: QuickList.java,v 1.6 2004/07/10 15:44:06 piratis Exp $
Author:
Jordi Martín

Nested Class Summary
 class QuickList.Enum
          Enumeration implementor
 
Constructor Summary
QuickList()
          Creates a quick list with an initial array size
QuickList(int initialSize)
          Creates a QuickList with an initial allocated space
 
Method Summary
 void add(java.lang.Object newObject)
          Adds a new object to the QuickList
 boolean contains(java.lang.Object obj)
          Tests if the specified object is a component in this vector.
 java.lang.Object elementAt(int intPosition)
          Returns the object at the given position
 java.util.Enumeration elements()
          Gets all the elements of the list
 java.util.Enumeration elements(int position)
          Gets all the elements of the list from one position
 void ensureCapacity(int minCapacity)
          Increases the capacity of this quicklist, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
 int indexOf(java.lang.Object obj)
          Searches for the first occurence of the given argument, testing for equality using the equals method.
 void insertElementAt(java.lang.Object newObject, int newPosition)
          Inserts the specified object as a component in this vector at the specified index.
 int length()
          Gets the number of objects within the list
 void removeAllElements()
          Remove all the objects of the list
 boolean removeElement(java.lang.Object obj)
          Removes the first occurrence of the argument from this quicklist.
 void removeElementAt(int position)
          Deletes the component at the specified index.
 void setElementAt(java.lang.Object newObject, int position)
          Sets the object at the given index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuickList

public QuickList()
Creates a quick list with an initial array size


QuickList

public QuickList(int initialSize)
Creates a QuickList with an initial allocated space

Parameters:
initialSize -
Method Detail

add

public final void add(java.lang.Object newObject)
Adds a new object to the QuickList

Parameters:
newObject - the newObject

insertElementAt

public final void insertElementAt(java.lang.Object newObject,
                                  int newPosition)
                           throws java.lang.IndexOutOfBoundsException
Inserts the specified object as a component in this vector at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.

The index must be a value greater than or equal to 0 and less than or equal to the current size of the vector.

Parameters:
newObject - the component to insert
newPosition - where to insert
Throws:
java.lang.IndexOutOfBoundsException - if the index was invalid

setElementAt

public final void setElementAt(java.lang.Object newObject,
                               int position)
                        throws java.lang.IndexOutOfBoundsException
Sets the object at the given index. The previous one at that position is removed from the QuickList.

Parameters:
newObject - new component to set
position - where to set this component
Throws:
java.lang.IndexOutOfBoundsException

elementAt

public final java.lang.Object elementAt(int intPosition)
                                 throws java.lang.IndexOutOfBoundsException,
                                        java.lang.NullPointerException
Returns the object at the given position

Parameters:
intPosition - the position
Returns:
the object
Throws:
java.lang.IndexOutOfBoundsException
java.lang.NullPointerException

length

public final int length()
Gets the number of objects within the list

Returns:
the number of objects

elements

public final java.util.Enumeration elements()
Gets all the elements of the list

Returns:
the whole collection of objects

elements

public final java.util.Enumeration elements(int position)
Gets all the elements of the list from one position

Parameters:
position - initial offset
Returns:
the whole collection of objects

removeElement

public final boolean removeElement(java.lang.Object obj)
Removes the first occurrence of the argument from this quicklist. If the object is found in this quicklist, each component in the quicklist with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously.

Parameters:
obj - the object to be removed
Returns:
true if the argument was a component of this quicklist; false otherwise.

removeElementAt

public final void removeElementAt(int position)
                           throws java.lang.IndexOutOfBoundsException
Deletes the component at the specified index. Each component in this quicklist with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously.

The index must be a value greater than or equal to 0 and less than the current size of the quicklist.

Parameters:
position - where the object to be remove is located
Throws:
java.lang.IndexOutOfBoundsException - if the index was invalid

removeAllElements

public final void removeAllElements()
Remove all the objects of the list


contains

public final boolean contains(java.lang.Object obj)
Tests if the specified object is a component in this vector.

Parameters:
obj - an object
Returns:
true if the specified object is a component in this vector; false otherwise.

indexOf

public final int indexOf(java.lang.Object obj)
Searches for the first occurence of the given argument, testing for equality using the equals method.

Parameters:
obj - an object
Returns:
the index of the first occurrence of the object argument in this quicklist at position index or later in the quicklist; returns -1 if the object is not found.

ensureCapacity

public final void ensureCapacity(int minCapacity)
Increases the capacity of this quicklist, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.

Parameters:
minCapacity - the desired minimum capacity.

Copyright(c) 2003-2004 Jordi Martin