org.openmobileis.common.util.collection
Class LongArray

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

public final class LongArray
extends java.lang.Object
implements OpenMISSerializable

Use to store an Array of long.

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

Field Summary
protected static long serialVersionUID
           
 
Constructor Summary
LongArray()
          Constructs an empty list.
LongArray(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
 
Method Summary
 boolean add(int index, long o)
          Appends the specified element to the end of this list.
 boolean add(long o)
          Appends the specified element to the end of this list.
 boolean add(long[] array)
          Appends the specified LongArray to the end of this list.
 boolean add(LongArray array)
          Appends the specified LongArray to the end of this list.
 void addIntersect(long[] array)
           
 void addUnion(long[] array)
           
 void clear()
           
static long[] diffLongArray(long[] array1, long[] array2)
          return a array containing all element of the second array that is not in the first one.
 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.
 long get(int index)
          Returns the element at the specified position in this list.
protected  long[] getArrayElements()
           
static long[] intersectLongArray(long[] array1, long[] array2)
           
 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, long 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.
protected  void setArrayElements(long[] array)
           
static void shellsort(long[] data)
           
 int size()
          Returns the number of elements in this list.
 long[] toArray()
          Returns an array containing all of the elements in this list in the correct order.
static long[] unionLongArray(long[] array1, long[] array2)
           
 
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

LongArray

public LongArray(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

LongArray

public LongArray()
Constructs an empty list.

Method Detail

clear

public void clear()

getArrayElements

protected long[] getArrayElements()

setArrayElements

protected void setArrayElements(long[] 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.

toArray

public long[] 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 long 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(long 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(LongArray 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(long[] 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,
                       long 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 index,
                   long 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()).

addIntersect

public void addIntersect(long[] array)

addUnion

public void addUnion(long[] array)

shellsort

public static void shellsort(long[] data)

intersectLongArray

public static long[] intersectLongArray(long[] array1,
                                        long[] array2)

unionLongArray

public static long[] unionLongArray(long[] array1,
                                    long[] array2)

diffLongArray

public static long[] diffLongArray(long[] array1,
                                   long[] array2)
return a array containing all element of the second array that is not in the first one.

Parameters:
array1 - first array
array2 - second array
Returns:
array of long that contained in the second array and not in the first.


Copyright 2006 OpenMobileIS. All Rights Reserved.