org.openmobileis.common.util.collection
Class IntArray

java.lang.Object
  extended byorg.openmobileis.common.util.collection.IntArray
All Implemented Interfaces:
java.io.Serializable

public final class IntArray
extends java.lang.Object
implements java.io.Serializable

Title: OpenMobileIS project source
Description: Use to store an Array of int.

Since:
JDK 1.1
Version:
1.0.
Author:
Philippe Delrieu
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
           
 
Constructor Summary
IntArray()
          Constructs an empty list.
IntArray(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
 
Method Summary
 boolean add(int o)
          Appends the specified element to the end of this list.
 boolean add(int[] array)
          Appends the specified LongArray to the end of this list.
 boolean add(IntArray array)
          Appends the specified LongArray to the end of this list.
 boolean add(int index, int o)
          Appends the specified element to the end of this list.
 void clear()
           
 boolean contains(int o)
          return true if the array contains the specified int false otherwise.
 void ensureCapacity(int minCapacity)
          Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
 int get(int index)
          Returns the element at the specified position in this list.
protected  int[] getArrayElements()
           
 boolean isEmpty()
          Tests if this list has no elements.
 long remove(int index)
          Removes the element at the specified position in this list.
 boolean replace(int index, int o)
          replace at the specified index the element.
protected  void setArrayElements(int[] array)
           
 int size()
          Returns the number of elements in this list.
 int[] toArray()
          Returns an array containing all of the elements in this list in the correct order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

IntArray

public IntArray(int initialCapacity)
Constructs an empty list with the specified initial capacity.

Parameters:
initialCapacity - the initial capacity of the list.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative

IntArray

public IntArray()
Constructs an empty list.

Method Detail

clear

public void clear()

getArrayElements

protected int[] getArrayElements()

setArrayElements

protected void setArrayElements(int[] array)

ensureCapacity

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

Parameters:
minCapacity - the desired minimum capacity.

size

public int size()
Returns the number of elements in this list.

Returns:
the number of elements in this list.

isEmpty

public boolean isEmpty()
Tests if this list has no elements.

Returns:
true if this list has no elements; false otherwise.

contains

public boolean contains(int o)
return true if the array contains the specified int false otherwise.

Returns:
true if the specified int is inside the array.

toArray

public int[] toArray()
Returns an array containing all of the elements in this list in the correct order.

Returns:
an array containing all of the elements in this list in the correct order.

get

public int get(int index)
Returns the element at the specified position in this list.

Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index >= size()).

add

public boolean add(int o)
Appends the specified element to the end of this list.

Parameters:
o - element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

add

public boolean add(IntArray array)
Appends the specified LongArray to the end of this list.

Parameters:
array - long to add.
Returns:
true (as per the general contract of Collection.add).

replace

public boolean replace(int index,
                       int o)
replace at the specified index the element. if there is no element at index add the new one at the end of the array.

Parameters:
index - index in the array where element is replaced.
o - element to be replaced to this ArrayList.
Returns:
true.

add

public boolean add(int[] array)
Appends the specified LongArray to the end of this list.

Parameters:
array - long to add.
Returns:
true (as per the general contract of Collection.add).

add

public boolean add(int index,
                   int o)
Appends the specified element to the end of this list.

Parameters:
o - element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

remove

public long remove(int index)
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).

Parameters:
index - the index of the element to removed.
Returns:
the element that was removed from the list.
Throws:
java.lang.IndexOutOfBoundsException - if index out of range (index < 0 || index >= size()).


Copyright 2006 OpenMobileIS. All Rights Reserved.