org.logicalcobwebs.proxool.util
类 FastArrayList

java.lang.Object
  继承者 java.util.AbstractCollection<E>
      继承者 java.util.AbstractList<E>
          继承者 java.util.ArrayList
              继承者 org.logicalcobwebs.proxool.util.FastArrayList
所有已实现的接口:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class FastArrayList
extends 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.

NOTE: This class is not cross-platform. Using it may cause unexpected failures on some architectures. It suffers from the same problems as the double-checked locking idiom. In particular, the instruction that clones the internal collection and the instruction that sets the internal reference to the clone can be executed or perceived out-of-order. This means that any read operation might fail unexpectedly, as it may be reading the state of the internal collection before the internal collection is fully formed. For more information on the double-checked locking idiom, see the Double-Checked Locking Idiom Is Broken Declartion.

从以下版本开始:
Proxool 0.6
版本:
$Revision: 1.4 $ $Date: 2003/03/10 23:43:18 $
作者:
Craig R. McClanahan, $Author: billhorsman $ (current maintainer)
另请参见:
序列化表格

字段摘要
 
从类 java.util.AbstractList 继承的字段
modCount
 
构造方法摘要
FastArrayList()
          Construct a an empty list.
FastArrayList(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, Object element)
          Insert the specified element at the specified position in this list, and shift all remaining elements up one position.
 boolean add(Object element)
          Appends the specified element to the end of this list.
 boolean addAll(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, 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.
 Object clone()
          Return a shallow copy of this FastArrayList instance.
 boolean contains(Object element)
          Return true if this list contains the specified element.
 boolean containsAll(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(Object o)
          Compare the specified object with this list for equality.
 Object get(int index)
          Return the element at the specified position in the list.
 boolean getFast()
          Returns true if this list is operating in fast mode.
 int hashCode()
          Return the hash code value for this list.
 int indexOf(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.
 Iterator iterator()
          Return an iterator over the elements in this list in proper sequence.
 int lastIndexOf(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.
 ListIterator listIterator()
          Return an iterator of the elements of this list, in proper sequence.
 ListIterator listIterator(int index)
          Return an iterator of the elements of this list, in proper sequence, starting at the specified position.
 Object remove(int index)
          Remove the element at the specified position in the list, and shift any subsequent elements down one position.
 boolean remove(Object element)
          Remove the first occurrence of the specified element from the list, and shift any subsequent elements down one position.
 boolean removeAll(Collection collection)
          Remove from this collection all of its elements that are contained in the specified collection.
 boolean retainAll(Collection collection)
          Remove from this collection all of its elements except those that are contained in the specified collection.
 Object set(int index, Object element)
          Replace the element at the specified position in this list with the specified element.
 void setFast(boolean fast)
          Sets whether this list will operate in fast mode.
 int size()
          Return the number of elements in this list.
 List subList(int fromIndex, int toIndex)
          Return a view of the portion of this list between fromIndex (inclusive) and toIndex (exclusive).
 Object[] toArray()
          Return an array containing all of the elements in this list in the correct order.
 Object[] toArray(Object[] array)
          Return an array containing all of the elements in this list in the correct order.
 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.util.ArrayList 继承的方法
removeRange
 
从类 java.lang.Object 继承的方法
finalize, getClass, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

FastArrayList

public FastArrayList()
Construct a an empty list.


FastArrayList

public FastArrayList(int capacity)
Construct an empty list with the specified capacity.

参数:
capacity - The initial capacity of the empty list

FastArrayList

public FastArrayList(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
方法详细信息

getFast

public boolean getFast()
Returns true if this list is operating in fast mode.

返回:
true if this list is operating in fast mode

setFast

public void setFast(boolean fast)
Sets whether this list will operate in fast mode.

参数:
fast - true if the list should operate in fast mode

add

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

指定者:
接口 Collection 中的 add
指定者:
接口 List 中的 add
覆盖:
ArrayList 中的 add
参数:
element - The element to be appended

add

public void add(int index,
                Object element)
Insert the specified element at the specified position in this list, and shift all remaining elements up one position.

指定者:
接口 List 中的 add
覆盖:
ArrayList 中的 add
参数:
index - Index at which to insert this element
element - The element to be inserted
抛出:
IndexOutOfBoundsException - if the index is out of range

addAll

public boolean addAll(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.

指定者:
接口 Collection 中的 addAll
指定者:
接口 List 中的 addAll
覆盖:
ArrayList 中的 addAll
参数:
collection - The collection to be appended

addAll

public boolean addAll(int index,
                      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.

指定者:
接口 List 中的 addAll
覆盖:
ArrayList 中的 addAll
参数:
index - Index at which insertion takes place
collection - The collection to be added
抛出:
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.

指定者:
接口 Collection 中的 clear
指定者:
接口 List 中的 clear
覆盖:
ArrayList 中的 clear
抛出:
UnsupportedOperationException - if clear() is not supported by this list

clone

public Object clone()
Return a shallow copy of this FastArrayList instance. The elements themselves are not copied.

覆盖:
ArrayList 中的 clone

contains

public boolean contains(Object element)
Return true if this list contains the specified element.

指定者:
接口 Collection 中的 contains
指定者:
接口 List 中的 contains
覆盖:
ArrayList 中的 contains
参数:
element - The element to test for

containsAll

public boolean containsAll(Collection collection)
Return true if this list contains all of the elements in the specified Collection.

指定者:
接口 Collection 中的 containsAll
指定者:
接口 List 中的 containsAll
覆盖:
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.

覆盖:
ArrayList 中的 ensureCapacity
参数:
capacity - The new minimum capacity

equals

public boolean equals(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.

指定者:
接口 Collection 中的 equals
指定者:
接口 List 中的 equals
覆盖:
AbstractList 中的 equals
参数:
o - Object to be compared to this list

get

public Object get(int index)
Return the element at the specified position in the list.

指定者:
接口 List 中的 get
覆盖:
ArrayList 中的 get
参数:
index - The index of the element to return
抛出:
IndexOutOfBoundsException - if the index is out of range

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.

指定者:
接口 Collection 中的 hashCode
指定者:
接口 List 中的 hashCode
覆盖:
AbstractList 中的 hashCode

indexOf

public int indexOf(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.

指定者:
接口 List 中的 indexOf
覆盖:
ArrayList 中的 indexOf
参数:
element - The element to search for

isEmpty

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

指定者:
接口 Collection 中的 isEmpty
指定者:
接口 List 中的 isEmpty
覆盖:
ArrayList 中的 isEmpty

iterator

public 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.

指定者:
接口 Iterable 中的 iterator
指定者:
接口 Collection 中的 iterator
指定者:
接口 List 中的 iterator
覆盖:
AbstractList 中的 iterator

lastIndexOf

public int lastIndexOf(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.

指定者:
接口 List 中的 lastIndexOf
覆盖:
ArrayList 中的 lastIndexOf
参数:
element - The element to search for

listIterator

public ListIterator listIterator()
Return an iterator of the elements of this list, in proper sequence. See the implementation note on iterator().

指定者:
接口 List 中的 listIterator
覆盖:
AbstractList 中的 listIterator

listIterator

public 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().

指定者:
接口 List 中的 listIterator
覆盖:
AbstractList 中的 listIterator
参数:
index - The starting position of the iterator to return
抛出:
IndexOutOfBoundsException - if the index is out of range

remove

public Object remove(int index)
Remove the element at the specified position in the list, and shift any subsequent elements down one position.

指定者:
接口 List 中的 remove
覆盖:
ArrayList 中的 remove
参数:
index - Index of the element to be removed
抛出:
IndexOutOfBoundsException - if the index is out of range

remove

public boolean remove(Object element)
Remove the first occurrence of the specified element from the list, and shift any subsequent elements down one position.

指定者:
接口 Collection 中的 remove
指定者:
接口 List 中的 remove
覆盖:
ArrayList 中的 remove
参数:
element - Element to be removed

removeAll

public boolean removeAll(Collection collection)
Remove from this collection all of its elements that are contained in the specified collection.

指定者:
接口 Collection 中的 removeAll
指定者:
接口 List 中的 removeAll
覆盖:
AbstractCollection 中的 removeAll
参数:
collection - Collection containing elements to be removed
抛出:
UnsupportedOperationException - if this optional operation is not supported by this list

retainAll

public boolean retainAll(Collection collection)
Remove from this collection all of its elements except those that are contained in the specified collection.

指定者:
接口 Collection 中的 retainAll
指定者:
接口 List 中的 retainAll
覆盖:
AbstractCollection 中的 retainAll
参数:
collection - Collection containing elements to be retained
抛出:
UnsupportedOperationException - if this optional operation is not supported by this list

set

public Object set(int index,
                  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.

指定者:
接口 List 中的 set
覆盖:
ArrayList 中的 set
参数:
index - Index of the element to replace
element - The new element to be stored
抛出:
IndexOutOfBoundsException - if the index is out of range

size

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

指定者:
接口 Collection 中的 size
指定者:
接口 List 中的 size
覆盖:
ArrayList 中的 size

subList

public 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.

指定者:
接口 List 中的 subList
覆盖:
AbstractList 中的 subList
参数:
fromIndex - The starting index of the sublist view
toIndex - The index after the end of the sublist view
抛出:
IndexOutOfBoundsException - if an index is out of range

toArray

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

指定者:
接口 Collection 中的 toArray
指定者:
接口 List 中的 toArray
覆盖:
ArrayList 中的 toArray

toArray

public Object[] toArray(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.

指定者:
接口 Collection 中的 toArray
指定者:
接口 List 中的 toArray
覆盖:
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 String toString()
Return a String representation of this object.

覆盖:
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.

覆盖:
ArrayList 中的 trimToSize


Copyright © 2014. All rights reserved.