org.apache.commons.collections
クラス FastArrayList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--org.apache.commons.collections.FastArrayList
すべての実装インタフェース:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class FastArrayList
extends java.util.ArrayList

A customized implementation of java.util.ArrayList designed to operate in a multithreaded environment where the large majority of method calls are read-only, instead of structural changes. When operating in "fast" mode, read calls are non-synchronized and write calls perform the following steps:

When first created, objects of this class default to "slow" mode, where all accesses of any type are synchronized but no cloning takes place. This is appropriate for initially populating the collection, followed by a switch to "fast" mode (by calling setFast(true)) after initialization is complete.

NOTE: If you are creating and accessing an ArrayList only within a single thread, you should use java.util.ArrayList directly (with no synchronization), for maximum performance.

バージョン:
$Revision: 1.3 $ $Date: 2001/05/20 21:03:30 $
作成者:
Craig R. McClanahan
関連項目:
直列化された形式

コンストラクタの概要
FastArrayList()
          Construct a an empty list.
FastArrayList(java.util.Collection collection)
          Construct a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
FastArrayList(int capacity)
          Construct an empty list with the specified capacity.
 
メソッドの概要
 void add(int index, java.lang.Object element)
          Insert the specified element at the specified position in this list, and shift all remaining elements up one position.
 boolean add(java.lang.Object element)
          Appends the specified element to the end of this list.
 boolean addAll(java.util.Collection collection)
          Append 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 collection)
          Insert all of the elements in the specified Collection at the specified position in this list, and shift any previous elements upwards as needed.
 void clear()
          Remove all of the elements from this list.
 java.lang.Object clone()
          Return a shallow copy of this FastArrayList instance.
 boolean contains(java.lang.Object element)
          Return true if this list contains the specified element.
 boolean containsAll(java.util.Collection collection)
          Return true if this list contains all of the elements in the specified Collection.
 void ensureCapacity(int capacity)
          Increase 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.
 boolean equals(java.lang.Object o)
          Compare the specified object with this list for equality.
 java.lang.Object get(int index)
          Return the element at the specified position in the list.
 boolean getFast()
           
 int hashCode()
          Return the hash code value for this list.
 int indexOf(java.lang.Object element)
          Search for the first occurrence of the given argument, testing for equality using the equals() method, and return the corresponding index, or -1 if the object is not found.
 boolean isEmpty()
          Test if this list has no elements.
 java.util.Iterator iterator()
          Return an iterator over the elements in this list in proper sequence.
 int lastIndexOf(java.lang.Object element)
          Search for the last occurrence of the given argument, testing for equality using the equals() method, and return the corresponding index, or -1 if the object is not found.
 java.util.ListIterator listIterator()
          Return an iterator of the elements of this list, in proper sequence.
 java.util.ListIterator listIterator(int index)
          Return an iterator of the elements of this list, in proper sequence, starting at the specified position.
 java.lang.Object remove(int index)
          Remove the element at the specified position in the list, and shift any subsequent elements down one position.
 boolean remove(java.lang.Object element)
          Remove the first occurrence of the specified element from the list, and shift any subsequent elements down one position.
 boolean removeAll(java.util.Collection collection)
          Remove from this collection all of its elements that are contained in the specified collection.
 boolean retainAll(java.util.Collection collection)
          Remove from this collection all of its elements except those that are contained in the specified collection.
 java.lang.Object set(int index, java.lang.Object element)
          Replace the element at the specified position in this list with the specified element.
 void setFast(boolean fast)
           
 int size()
          Return the number of elements in this list.
 java.util.List subList(int fromIndex, int toIndex)
          Return a view of the portion of this list between fromIndex (inclusive) and toIndex (exclusive).
 java.lang.Object[] toArray()
          Return an array containing all of the elements in this list in the correct order.
 java.lang.Object[] toArray(java.lang.Object[] array)
          Return an array containing all of the elements in this list in the correct order.
 java.lang.String toString()
          Return a String representation of this object.
 void trimToSize()
          Trim the capacity of this ArrayList instance to be the list's current size.
 
クラス java.lang.Object から継承したメソッド
getClass, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

FastArrayList

public FastArrayList()
Construct a an empty list.

FastArrayList

public FastArrayList(java.util.Collection collection)
Construct a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
パラメータ:
collection - The collection whose elements initialize the contents of this list

FastArrayList

public FastArrayList(int capacity)
Construct an empty list with the specified capacity.
パラメータ:
capacity - The initial capacity of the empty list
メソッドの詳細

add

public void add(int index,
                java.lang.Object element)
Insert the specified element at the specified position in this list, and shift all remaining elements up one position.
オーバーライド:
クラス java.util.ArrayList 内の add
パラメータ:
index - Index at which to insert this element
element - The element to be inserted
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range

add

public boolean add(java.lang.Object element)
Appends the specified element to the end of this list.
オーバーライド:
クラス java.util.ArrayList 内の add
パラメータ:
element - The element to be appended

addAll

public boolean addAll(java.util.Collection collection)
Append 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.
オーバーライド:
クラス java.util.ArrayList 内の addAll
パラメータ:
collection - The collection to be appended

addAll

public boolean addAll(int index,
                      java.util.Collection collection)
Insert all of the elements in the specified Collection at the specified position in this list, and shift any previous elements upwards as needed.
オーバーライド:
クラス java.util.ArrayList 内の addAll
パラメータ:
index - Index at which insertion takes place
collection - The collection to be added
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range

clear

public void clear()
Remove all of the elements from this list. The list will be empty after this call returns.
オーバーライド:
クラス java.util.ArrayList 内の clear
例外:
java.lang.UnsupportedOperationException - if clear() is not supported by this list

clone

public java.lang.Object clone()
Return a shallow copy of this FastArrayList instance. The elements themselves are not copied.
オーバーライド:
クラス java.util.ArrayList 内の clone

contains

public boolean contains(java.lang.Object element)
Return true if this list contains the specified element.
オーバーライド:
クラス java.util.ArrayList 内の contains
パラメータ:
element - The element to test for

containsAll

public boolean containsAll(java.util.Collection collection)
Return true if this list contains all of the elements in the specified Collection.
オーバーライド:
クラス java.util.AbstractCollection 内の containsAll
パラメータ:
collection - Collection whose elements are to be checked

ensureCapacity

public void ensureCapacity(int capacity)
Increase 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.
オーバーライド:
クラス java.util.ArrayList 内の ensureCapacity
パラメータ:
capacity - The new minimum capacity

equals

public boolean equals(java.lang.Object o)
Compare the specified object with this list for equality. This implementation uses exactly the code that is used to define the list equals function in the documentation for the List.equals method.
オーバーライド:
クラス java.util.AbstractList 内の equals
パラメータ:
o - Object to be compared to this list

get

public java.lang.Object get(int index)
Return the element at the specified position in the list.
オーバーライド:
クラス java.util.ArrayList 内の get
パラメータ:
index - The index of the element to return
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range

getFast

public boolean getFast()

hashCode

public int hashCode()
Return the hash code value for this list. This implementation uses exactly the code that is used to define the list hash function in the documentation for the List.hashCode method.
オーバーライド:
クラス java.util.AbstractList 内の hashCode

indexOf

public int indexOf(java.lang.Object element)
Search for the first occurrence of the given argument, testing for equality using the equals() method, and return the corresponding index, or -1 if the object is not found.
オーバーライド:
クラス java.util.ArrayList 内の indexOf
パラメータ:
element - The element to search for

isEmpty

public boolean isEmpty()
Test if this list has no elements.
オーバーライド:
クラス java.util.ArrayList 内の isEmpty

iterator

public java.util.Iterator iterator()
Return an iterator over the elements in this list in proper sequence.

IMPLEMENTATION NOTE - If the list is operating in fast mode, an Iterator is returned, and a structural modification to the list is made, then the Iterator will continue over the previous contents of the list (at the time that the Iterator was created), rather than failing due to concurrent modifications.
オーバーライド:
クラス java.util.AbstractList 内の iterator

lastIndexOf

public int lastIndexOf(java.lang.Object element)
Search for the last occurrence of the given argument, testing for equality using the equals() method, and return the corresponding index, or -1 if the object is not found.
オーバーライド:
クラス java.util.ArrayList 内の lastIndexOf
パラメータ:
element - The element to search for

listIterator

public java.util.ListIterator listIterator()
Return an iterator of the elements of this list, in proper sequence. See the implementation note on iterator().
オーバーライド:
クラス java.util.AbstractList 内の listIterator

listIterator

public java.util.ListIterator listIterator(int index)
Return an iterator of the elements of this list, in proper sequence, starting at the specified position. See the implementation note on iterator().
オーバーライド:
クラス java.util.AbstractList 内の listIterator
パラメータ:
index - The starting position of the iterator to return
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range

remove

public java.lang.Object remove(int index)
Remove the element at the specified position in the list, and shift any subsequent elements down one position.
オーバーライド:
クラス java.util.ArrayList 内の remove
パラメータ:
index - Index of the element to be removed
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range

remove

public boolean remove(java.lang.Object element)
Remove the first occurrence of the specified element from the list, and shift any subsequent elements down one position.
オーバーライド:
クラス java.util.AbstractCollection 内の remove
パラメータ:
element - Element to be removed

removeAll

public boolean removeAll(java.util.Collection collection)
Remove from this collection all of its elements that are contained in the specified collection.
オーバーライド:
クラス java.util.AbstractCollection 内の removeAll
パラメータ:
collection - Collection containing elements to be removed
例外:
java.lang.UnsupportedOperationException - if this optional operation is not supported by this list

retainAll

public boolean retainAll(java.util.Collection collection)
Remove from this collection all of its elements except those that are contained in the specified collection.
オーバーライド:
クラス java.util.AbstractCollection 内の retainAll
パラメータ:
collection - Collection containing elements to be retained
例外:
java.lang.UnsupportedOperationException - if this optional operation is not supported by this list

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Replace the element at the specified position in this list with the specified element. Returns the previous object at that position.

IMPLEMENTATION NOTE - This operation is specifically documented to not be a structural change, so it is safe to be performed without cloning.
オーバーライド:
クラス java.util.ArrayList 内の set
パラメータ:
index - Index of the element to replace
element - The new element to be stored
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range

setFast

public void setFast(boolean fast)

size

public int size()
Return the number of elements in this list.
オーバーライド:
クラス java.util.ArrayList 内の size

subList

public java.util.List subList(int fromIndex,
                              int toIndex)
Return a view of the portion of this list between fromIndex (inclusive) and toIndex (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list. The returned list supports all of the optional list operations supported by this list.
オーバーライド:
クラス java.util.AbstractList 内の subList
パラメータ:
fromIndex - The starting index of the sublist view
toIndex - The index after the end of the sublist view
例外:
java.lang.IndexOutOfBoundsException - if an index is out of range

toArray

public java.lang.Object[] toArray()
Return an array containing all of the elements in this list in the correct order.
オーバーライド:
クラス java.util.ArrayList 内の toArray

toArray

public java.lang.Object[] toArray(java.lang.Object[] array)
Return 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.
オーバーライド:
クラス java.util.ArrayList 内の toArray
パラメータ:
array - Array defining the element type of the returned list
例外:
ArrayStoreException - if the runtime type of array is not a supertype of the runtime type of every element in this list

toString

public java.lang.String toString()
Return a String representation of this object.
オーバーライド:
クラス java.util.AbstractCollection 内の toString

trimToSize

public void trimToSize()
Trim the capacity of this ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.
オーバーライド:
クラス java.util.ArrayList 内の trimToSize


Copyright © 2001 Apache Software Foundation. Documenation generated November 5 2001.