Skip navigation links


com.essbase.eas.utils
Class SortedArrayList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by com.essbase.eas.utils.SortedArrayList

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List

public class SortedArrayList
extends java.util.AbstractList
implements java.util.List, java.lang.Cloneable, java.io.Serializable
See Also:
Serialized Form

Field Summary

 

Fields inherited from class java.util.AbstractList
modCount

 

Constructor Summary
SortedArrayList()
          Constructs an empty list with an initial capacity of ten.
SortedArrayList(java.util.Collection c)
          Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
SortedArrayList(int initialCapacity)
          Constructs an empty list with the specified initial capacity.

 

Method Summary
 void add(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this list.
 boolean add(java.util.List list)
           
 boolean add(java.lang.Object o)
          Appends the specified element to the end of this list.
 boolean add(java.lang.Object[] o)
          Appends the specified element to the end of this list.
 boolean addAll(java.util.Collection c)
          Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.
 boolean addAll(int index, java.util.Collection c)
          Inserts all of the elements in the specified Collection into this list, starting at the specified position.
 void clear()
          Removes all of the elements from this list.
 java.lang.Object clone()
          Returns a shallow copy of this SortedArrayList instance.
 boolean contains(java.lang.Object elem)
          Returns true if this list contains the specified element.
 void ensureCapacity(int minCapacity)
          Increases the capacity of this SortedArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
 java.lang.Object get(int index)
          Returns the element at the specified position in this list.
 int indexOf(java.lang.Object elem)
          Searches for the first occurence of the given argument, testing for equality using the equals method.
 boolean isEmpty()
          Tests if this list has no elements.
 int lastIndexOf(java.lang.Object elem)
          Returns the index of the last occurrence of the specified object in this list.
 java.lang.Object remove(int index)
          Removes the element at the specified position in this list.
protected  void removeRange(int fromIndex, int toIndex)
          Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.
 int search(java.lang.Object searchObject)
           
 java.lang.Object set(int index, java.lang.Object element)
          Replaces the element at the specified position in this list with the specified element.
 void setIgnoreCase(boolean ignore)
           
 int size()
          Returns the number of elements in this list.
 void sort()
           
 java.lang.Object[] toArray()
          Returns an array containing all of the elements in this list in the correct order.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array.
 void trimToSize()
          Trims the capacity of this SortedArrayList instance to be the list's current size.

 

Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList

 

Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll, toString

 

Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait

 

Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList

 

Constructor Detail

SortedArrayList

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

SortedArrayList

public SortedArrayList()
Constructs an empty list with an initial capacity of ten.

SortedArrayList

public SortedArrayList(java.util.Collection c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. The SortedArrayList instance has an initial capacity of 110% the size of the specified collection.
Parameters:
c - the collection whose elements are to be placed into this list.
Throws:
java.lang.NullPointerException - if the specified collection is null.

Method Detail

trimToSize

public void trimToSize()
Trims the capacity of this SortedArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an SortedArrayList instance.

ensureCapacity

public void ensureCapacity(int minCapacity)
Increases the capacity of this SortedArrayList 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.
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List
Specified by:
size in class java.util.AbstractCollection
Returns:
the number of elements in this list.

isEmpty

public boolean isEmpty()
Tests if this list has no elements.
Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.List
Overrides:
isEmpty in class java.util.AbstractCollection
Returns:
true if this list has no elements; false otherwise.

contains

public boolean contains(java.lang.Object elem)
Returns true if this list contains the specified element.
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.List
Overrides:
contains in class java.util.AbstractCollection
Parameters:
elem - element whose presence in this List is to be tested.
Returns:
true if the specified element is present; false otherwise.

indexOf

public int indexOf(java.lang.Object elem)
Searches for the first occurence of the given argument, testing for equality using the equals method.
Specified by:
indexOf in interface java.util.List
Overrides:
indexOf in class java.util.AbstractList
Parameters:
elem - an object.
Returns:
the index of the first occurrence of the argument in this list; returns -1 if the object is not found.
See Also:
Object.equals(Object)

lastIndexOf

public int lastIndexOf(java.lang.Object elem)
Returns the index of the last occurrence of the specified object in this list.
Specified by:
lastIndexOf in interface java.util.List
Overrides:
lastIndexOf in class java.util.AbstractList
Parameters:
elem - the desired element.
Returns:
the index of the last occurrence of the specified object in this list; returns -1 if the object is not found.

clone

public java.lang.Object clone()
Returns a shallow copy of this SortedArrayList instance. (The elements themselves are not copied.)
Overrides:
clone in class java.lang.Object
Returns:
a clone of this SortedArrayList instance.

toArray

public java.lang.Object[] toArray()
Returns an array containing all of the elements in this list in the correct order.
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List
Overrides:
toArray in class java.util.AbstractCollection
Returns:
an array containing all of the elements in this list in the correct order.

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.

If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.

Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List
Overrides:
toArray in class java.util.AbstractCollection
Parameters:
a - the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of the list.
Throws:
java.lang.ArrayStoreException - if the runtime type of a is not a supertype of the runtime type of every element in this list.

get

public java.lang.Object get(int index)
Returns the element at the specified position in this list.
Specified by:
get in interface java.util.List
Specified by:
get in class java.util.AbstractList
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()).

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Replaces the element at the specified position in this list with the specified element.
Specified by:
set in interface java.util.List
Overrides:
set in class java.util.AbstractList
Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Returns:
the element previously at the specified position.
Throws:
java.lang.IndexOutOfBoundsException - if index out of range (index < 0 || index >= size()).

add

public boolean add(java.lang.Object o)
Appends the specified element to the end of this list.
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.AbstractList
Parameters:
o - element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

add

public boolean add(java.lang.Object[] o)
Appends the specified element to the end of this list.
Parameters:
o - array element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

add

public boolean add(java.util.List list)

add

public void add(int index,
                java.lang.Object element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.AbstractList
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index > size()).

remove

public java.lang.Object 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).
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.AbstractList
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()).

clear

public void clear()
Removes all of the elements from this list. The list will be empty after this call returns.
Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List
Overrides:
clear in class java.util.AbstractList

addAll

public boolean addAll(java.util.Collection c)
Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator. The behavior of this operation is undefined if the specified Collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this list, and this list is nonempty.)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.AbstractCollection
Parameters:
c - the elements to be inserted into this list.
Returns:
true if this list changed as a result of the call.
Throws:
java.lang.IndexOutOfBoundsException - if index out of range (index < 0 || index > size()).
java.lang.NullPointerException - if the specified collection is null.

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Inserts all of the elements in the specified Collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified Collection's iterator.
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.AbstractList
Parameters:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this list.
Returns:
true if this list changed as a result of the call.
Throws:
java.lang.IndexOutOfBoundsException - if index out of range (index < 0 || index > size()).
java.lang.NullPointerException - if the specified Collection is null.

removeRange

protected void removeRange(int fromIndex,
                           int toIndex)
Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the list by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation has no effect.)
Overrides:
removeRange in class java.util.AbstractList
Parameters:
fromIndex - index of first element to be removed.
toIndex - index after last element to be removed.

sort

public void sort()

search

public int search(java.lang.Object searchObject)

setIgnoreCase

public void setIgnoreCase(boolean ignore)

Skip navigation links


Copyright © 2001, 2012, Oracle. All rights reserved.