org.apache.commons.collections
クラス CursorableLinkedList

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

public class CursorableLinkedList
extends java.lang.Object
implements java.util.List, java.io.Serializable

A doubly-linked list implementation of the List interface, supporting a ListIterator that allows concurrent modifications to the underlying list.

Implements all of the optional List operations, the stack/queue/dequeue operations available in LinkedList and supports a ListIterator that allows concurrent modifications to the underlying list (see cursor()).

Note that this implementation is not synchronized.

バージョン:
$Id: CursorableLinkedList.java,v 1.3 2001/05/04 16:33:13 rwaldhoff Exp $
作成者:
Rodney Waldhoff
関連項目:
LinkedList, 直列化された形式

内部クラスの概要
 class CursorableLinkedList.Cursor
           
 
コンストラクタの概要
CursorableLinkedList()
           
 
メソッドの概要
 void add(int index, java.lang.Object element)
          Inserts the specified element at the specified position in 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 at the specified position.
 boolean addFirst(java.lang.Object o)
          Inserts the specified element at the beginning of this list.
 boolean addLast(java.lang.Object o)
          Inserts the specified element at the end of this list.
 void clear()
          Removes all of the elements from this list.
 boolean contains(java.lang.Object o)
          Returns true if this list contains the specified element.
 boolean containsAll(java.util.Collection c)
          Returns true if this list contains all of the elements of the specified collection.
 CursorableLinkedList.Cursor cursor()
          Returns a ListIterator for iterating through the elements of this list.
 CursorableLinkedList.Cursor cursor(int i)
          Returns a ListIterator for iterating through the elements of this list, initialized such that ListIterator.next() will return the element at the specified index (if any) and ListIterator.previous() will return the element immediately preceeding it (if any).
 boolean equals(java.lang.Object o)
          Compares the specified object with this list for equality.
 java.lang.Object get(int index)
          Returns the element at the specified position in this list.
 java.lang.Object getFirst()
          Returns the element at the beginning of this list.
 java.lang.Object getLast()
          Returns the element at the end of this list.
 int hashCode()
          Returns the hash code value for this list.
 int indexOf(java.lang.Object o)
          Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
 boolean isEmpty()
          Returns true if this list contains no elements.
 java.util.Iterator iterator()
          Returns a fail-fast iterator.
 int lastIndexOf(java.lang.Object o)
          Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
 java.util.ListIterator listIterator()
          Returns a fail-fast ListIterator.
 java.util.ListIterator listIterator(int index)
          Returns a fail-fast ListIterator.
 java.lang.Object remove(int index)
          Removes the element at the specified position in this list (optional operation).
 boolean remove(java.lang.Object o)
          Removes the first occurrence in this list of the specified element.
 boolean removeAll(java.util.Collection c)
          Removes from this list all the elements that are contained in the specified collection.
 java.lang.Object removeFirst()
          Removes the first element of this list, if any.
 java.lang.Object removeLast()
          Removes the last element of this list, if any.
 boolean retainAll(java.util.Collection c)
          Retains only the elements in this list that are contained in the specified collection.
 java.lang.Object set(int index, java.lang.Object element)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Returns the number of elements in this list.
 java.util.List subList(int i, int j)
          Returns a fail-fast sublist.
 java.lang.Object[] toArray()
          Returns an array containing all of the elements in this list in proper sequence.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array.
 java.lang.String toString()
          Returns a String representation of this list, suitable for debugging.
 
クラス java.lang.Object から継承したメソッド
getClass, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

CursorableLinkedList

public CursorableLinkedList()
メソッドの詳細

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).
定義:
インタフェース java.util.List 内の add
パラメータ:
index - index at which the specified element is to be inserted.
element - element to be inserted.
例外:
java.lang.ClassCastException - if the class of the specified element prevents it from being added to this list.
java.lang.IllegalArgumentException - if some aspect of the specified element prevents it from being added to this list.
java.lang.IndexOutOfBoundsException - if the index is 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.
定義:
インタフェース java.util.List 内の add
パラメータ:
o - element to be appended to this list.
戻り値:
true

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 unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
定義:
インタフェース java.util.List 内の addAll
パラメータ:
c - collection whose elements are to be added to this list.
戻り値:
true if this list changed as a result of the call.
例外:
java.lang.ClassCastException - if the class of an element in the specified collection prevents it from being added to this list.
java.lang.IllegalArgumentException - if some aspect of an element in the specified collection prevents it from being added to this list.

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Inserts all of the elements in the specified collection into this list 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 this list in the order that they are returned by the specified Collection's Iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
定義:
インタフェース java.util.List 内の addAll
パラメータ:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this list.
戻り値:
true if this list changed as a result of the call.
例外:
java.lang.ClassCastException - if the class of one of elements of the specified collection prevents it from being added to this list.
java.lang.IllegalArgumentException - if some aspect of one of elements of the specified collection prevents it from being added to this list.
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

addFirst

public boolean addFirst(java.lang.Object o)
Inserts the specified element at the beginning of this list. (Equivalent to add(0,o)).
パラメータ:
o - element to be prepended to this list.
戻り値:
true

addLast

public boolean addLast(java.lang.Object o)
Inserts the specified element at the end of this list. (Equivalent to add(java.lang.Object)).
パラメータ:
o - element to be appended to this list.
戻り値:
true

clear

public void clear()
Removes all of the elements from this list. This list will be empty after this call returns (unless it throws an exception).
定義:
インタフェース java.util.List 内の clear

contains

public boolean contains(java.lang.Object o)
Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).
定義:
インタフェース java.util.List 内の contains
パラメータ:
o - element whose presence in this list is to be tested.
戻り値:
true if this list contains the specified element.

containsAll

public boolean containsAll(java.util.Collection c)
Returns true if this list contains all of the elements of the specified collection.
定義:
インタフェース java.util.List 内の containsAll
パラメータ:
c - collection to be checked for containment in this list.
戻り値:
true if this list contains all of the elements of the specified collection.

cursor

public CursorableLinkedList.Cursor cursor()
Returns a ListIterator for iterating through the elements of this list. Unlike iterator(), a cursor is not bothered by concurrent modifications to the underlying list.

Specifically, when elements are added to the list before or after the cursor, the cursor simply picks them up automatically. When the "current" (i.e., last returned by ListIterator.next() or ListIterator.previous()) element of the list is removed, the cursor automatically adjusts to the change (invalidating the last returned value--i.e., it cannot be removed).

Note that the returned ListIterator does not support the ListIterator.nextIndex() and ListIterator.previousIndex() methods (they throw UnsupportedOperationException when invoked.

Clients must close the cursor when they are done using it. The returned ListIterator will be an instance of CursorableLinkedList.Cursor. To close the cursor, cast the ListIterator to CursorableLinkedList.Cursor and invoke the CursorableLinkedList.Cursor.close() method.

関連項目:
cursor(int), listIterator(), CursorableLinkedList.Cursor

cursor

public CursorableLinkedList.Cursor cursor(int i)
Returns a ListIterator for iterating through the elements of this list, initialized such that ListIterator.next() will return the element at the specified index (if any) and ListIterator.previous() will return the element immediately preceeding it (if any). Unlike iterator(), a cursor is not bothered by concurrent modifications to the underlying list.
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).
関連項目:
cursor(), listIterator(int), CursorableLinkedList.Cursor

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.
定義:
インタフェース java.util.List 内の equals
オーバーライド:
クラス java.lang.Object 内の equals
パラメータ:
o - the object to be compared for equality with this list.
戻り値:
true if the specified object is equal to this list.

get

public java.lang.Object get(int index)
Returns the element at the specified position in this list.
定義:
インタフェース java.util.List 内の get
パラメータ:
index - index of element to return.
戻り値:
the element at the specified position in this list.
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

getFirst

public java.lang.Object getFirst()
Returns the element at the beginning of this list.

getLast

public java.lang.Object getLast()
Returns the element at the end of this list.

hashCode

public int hashCode()
Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
  hashCode = 1;
  Iterator i = list.iterator();
  while (i.hasNext()) {
      Object obj = i.next();
      hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
  }
 
This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object.hashCode.
定義:
インタフェース java.util.List 内の hashCode
オーバーライド:
クラス java.lang.Object 内の hashCode
戻り値:
the hash code value for this list.
関連項目:
Object.hashCode(), Object.equals(Object), equals(Object)

indexOf

public int indexOf(java.lang.Object o)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
定義:
インタフェース java.util.List 内の indexOf
パラメータ:
o - element to search for.
戻り値:
the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

isEmpty

public boolean isEmpty()
Returns true if this list contains no elements.
定義:
インタフェース java.util.List 内の isEmpty
戻り値:
true if this list contains no elements.

iterator

public java.util.Iterator iterator()
Returns a fail-fast iterator.
定義:
インタフェース java.util.List 内の iterator
関連項目:
List.iterator()

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
定義:
インタフェース java.util.List 内の lastIndexOf
パラメータ:
o - element to search for.
戻り値:
the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.

listIterator

public java.util.ListIterator listIterator()
Returns a fail-fast ListIterator.
定義:
インタフェース java.util.List 内の listIterator
関連項目:
List.listIterator()

listIterator

public java.util.ListIterator listIterator(int index)
Returns a fail-fast ListIterator.
定義:
インタフェース java.util.List 内の listIterator
関連項目:
List.listIterator(int)

remove

public java.lang.Object remove(int index)
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
定義:
インタフェース java.util.List 内の remove
パラメータ:
index - the index of the element to removed.
戻り値:
the element previously at the specified position.
例外:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

remove

public boolean remove(java.lang.Object o)
Removes the first occurrence in this list of the specified element. If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).
定義:
インタフェース java.util.List 内の remove
パラメータ:
o - element to be removed from this list, if present.
戻り値:
true if this list contained the specified element.

removeAll

public boolean removeAll(java.util.Collection c)
Removes from this list all the elements that are contained in the specified collection.
定義:
インタフェース java.util.List 内の removeAll
パラメータ:
c - collection that defines which elements will be removed from this list.
戻り値:
true if this list changed as a result of the call.

removeFirst

public java.lang.Object removeFirst()
Removes the first element of this list, if any.

removeLast

public java.lang.Object removeLast()
Removes the last element of this list, if any.

retainAll

public boolean retainAll(java.util.Collection c)
Retains only the elements in this list that are contained in the specified collection. In other words, removes from this list all the elements that are not contained in the specified collection.
定義:
インタフェース java.util.List 内の retainAll
パラメータ:
c - collection that defines which elements this set will retain.
戻り値:
true if this list changed as a result of the call.

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.
定義:
インタフェース java.util.List 内の set
パラメータ:
index - index of element to replace.
element - element to be stored at the specified position.
戻り値:
the element previously at the specified position.
例外:
java.lang.ClassCastException - if the class of the specified element prevents it from being added to this list.
java.lang.IllegalArgumentException - if some aspect of the specified element prevents it from being added to this list.
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

size

public int size()
Returns the number of elements in this list.
定義:
インタフェース java.util.List 内の size
戻り値:
the number of elements in this list.

subList

public java.util.List subList(int i,
                              int j)
Returns a fail-fast sublist.
定義:
インタフェース java.util.List 内の subList
関連項目:
List.subList(int,int)

toArray

public java.lang.Object[] toArray()
Returns an array containing all of the elements in this list in proper sequence. Obeys the general contract of the Collection.toArray() method.
定義:
インタフェース java.util.List 内の toArray
戻り値:
an array containing all of the elements in this list in proper sequence.

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array. Obeys the general contract of the Collection.toArray() method.
定義:
インタフェース java.util.List 内の toArray
パラメータ:
a - the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
戻り値:
an array containing the elements of this list.
例外:
ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this list.

toString

public java.lang.String toString()
Returns a String representation of this list, suitable for debugging.
オーバーライド:
クラス java.lang.Object 内の toString
戻り値:
a String representation of this list, suitable for debugging.


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