Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.javatools.buffer
Class SafeArrayList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by oracle.javatools.buffer.SafeArrayList

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

public final class SafeArrayList
extends java.util.AbstractList
implements java.util.RandomAccess, java.lang.Cloneable

The SafeArrayList is an array List implementation that provides basic thread-safety by implementing a copy-on-write scheme. Because of this, fetching an Iterator or ListIterator would return a snapshot of the list data at the time the iterators were fetched.

Although this class is declared public, it is part of the implementation, and not part of the published API.


Nested Class Summary
protected static class SafeArrayList.SafeListIterator
          A list iterator implementation based on a static array.

 

Field Summary

 

Fields inherited from class java.util.AbstractList
modCount

 

Constructor Summary
SafeArrayList()
          Construct an empty list.
SafeArrayList(java.util.Collection c)
          Construct a list containing the elements of the specified collection in the order that they are returned by the collections iterator.

 

Method Summary
 void add(int index, java.lang.Object element)
          Inserts the given element at the given position in this list, shifting any element down.
 boolean add(java.lang.Object element)
          Adds (append) the given element to the end of our list.
 boolean addAll(java.util.Collection c)
          Adds (appends) all of the elements in the given collection to the end of this list.
 boolean addAll(int index, java.util.Collection c)
          Inserts all of the elements of the given collection to this list at the specified index.
 void clear()
          Empties this list.
 java.lang.Object clone()
          Returns a shallow copy of this list instance.
 boolean contains(java.lang.Object element)
          Fetch whether the given object is contained in this list.
 java.lang.Object get(int index)
          Fetch the element at the specified position in this list
 int indexOf(java.lang.Object element)
          Search for the first occurrence of the given argument, testing for equality using the equals() method.
 boolean isEmpty()
          Tests if this list is empty.
 java.util.Iterator iterator()
          Returns 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 in the list.
 java.util.ListIterator listIterator()
          Returns a list iterator of the elements in this list in proper sequnce.
 java.util.ListIterator listIterator(int index)
          Returns a list iterator of the elements in this list in proper sequence, starting at the given index.
 java.lang.Object remove(int index)
          Removes the element at the specified position in this list.
 boolean remove(java.lang.Object element)
          Removes a single instance of the specified element from this collection.
 boolean removeAll(java.util.Collection c)
          This operation is not supported by this list implementation.
protected  void removeRange(int startIndex, int endIndex)
          Removes from this list all of the elements between the given indexes.
 boolean retainAll(java.util.Collection c)
          This operation is not supported by this list implementation.
 java.lang.Object set(int index, java.lang.Object element)
          Replace the element at the specified position in this list with the specified element
 int size()
          Fetch the number of elements in this list.
 java.util.List subList(int startIndex, int endIndex)
          This operation is not supported by this list implementation.
 java.lang.Object[] toArray()
          Return an array containing all of the elements in the list in the same order.
 java.lang.Object[] toArray(java.lang.Object[] array)
          Return an array containing all of the elements in this list in the same order.
 java.lang.String toString()
          Fetch a visible representation of this object.

 

Methods inherited from class java.util.AbstractList
equals, hashCode

 

Methods inherited from class java.util.AbstractCollection
containsAll

 

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

 

Methods inherited from interface java.util.List
containsAll

 

Constructor Detail

SafeArrayList

public SafeArrayList()
Construct an empty list.

SafeArrayList

public SafeArrayList(java.util.Collection c)
Construct a list containing the elements of the specified collection in the order that they are returned by the collections iterator.

Method Detail

size

public int size()
Fetch 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 is empty.
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 is empty, false otherwise

contains

public boolean contains(java.lang.Object element)
Fetch whether the given object is contained in this list.
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.List
Overrides:
contains in class java.util.AbstractCollection
Parameters:
element - the element to check
Returns:
true if the list contains the given element

indexOf

public int indexOf(java.lang.Object element)
Search for the first occurrence 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:
element - the element to check
Returns:
the index of the first occurrence of the argument in this list, or -1 if not found

lastIndexOf

public int lastIndexOf(java.lang.Object element)
Search for the last occurrence of the given argument in the list.
Specified by:
lastIndexOf in interface java.util.List
Overrides:
lastIndexOf in class java.util.AbstractList
Parameters:
element - the element to check
Returns:
the index of the last occurrence of the argument in this list, or -1 if not found

clone

public java.lang.Object clone()
Returns a shallow copy of this list instance.
Overrides:
clone in class java.lang.Object
Returns:
a clone of this SafeArrayList instance

toArray

public java.lang.Object[] toArray()
Return an array containing all of the elements in the list in the same 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 the elements of the list

toArray

public java.lang.Object[] toArray(java.lang.Object[] array)
Return an array containing all of the elements in this list in the same order. Use the same type for the returned array as the specified array.
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List
Overrides:
toArray in class java.util.AbstractCollection
Parameters:
array - the array into which to store the elements of the list (if it is big enough)
Returns:
an array containing the elements of this list

get

public java.lang.Object get(int index)
Fetch 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 - the index of the element to return
Returns:
the element at the given index

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
Specified by:
set in interface java.util.List
Overrides:
set in class java.util.AbstractList
Parameters:
index - the index of the element to replace
element - the replacement element
Returns:
the element previously stored at the given position

add

public boolean add(java.lang.Object element)
Adds (append) the given element to the end of our 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:
element - the element to add
Returns:
true always

add

public void add(int index,
                java.lang.Object element)
Inserts the given element at the given position in this list, shifting any element down.
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.AbstractList
Parameters:
index - the index at which to insert the element
element - the element to insert

remove

public boolean remove(java.lang.Object element)
Removes a single instance of the specified element from this collection.
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.AbstractCollection
Parameters:
element - the element to be removed
Returns:
true if the element contained the given element

remove

public java.lang.Object remove(int index)
Removes the element at the specified position in this list. Shifts any element up.
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.AbstractList
Parameters:
index - the index of the element to remove
Returns:
the element that was removed

clear

public void clear()
Empties this list.
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)
Adds (appends) all of the elements in the given collection to the end of this list.
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 appended to this list
Returns:
true if the contents of this list changed (collection to be added was not empty)

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Inserts all of the elements of the given collection to this list at the specified index.
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.AbstractList
Parameters:
index - the location in which to insert the new elements
c - the collection to add to our list
Returns:
true if the contents of this list changed (collection to be added was not empty)

removeAll

public boolean removeAll(java.util.Collection c)
This operation is not supported by this list implementation.
Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.List
Overrides:
removeAll in class java.util.AbstractCollection

retainAll

public boolean retainAll(java.util.Collection c)
This operation is not supported by this list implementation.
Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.List
Overrides:
retainAll in class java.util.AbstractCollection

removeRange

protected void removeRange(int startIndex,
                           int endIndex)
Removes from this list all of the elements between the given indexes.
Overrides:
removeRange in class java.util.AbstractList
Parameters:
startIndex - the index to start the removal from (inclusive)
endIndex - the index to end the removal at (exclusive)

iterator

public java.util.Iterator iterator()
Returns an iterator over the elements in this list in proper sequence. This iterator does not support removal of elements, and is represents a snapshot of the contents of this list at the time the iterator is fetched.
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.List
Overrides:
iterator in class java.util.AbstractList
Returns:
an iterator over the elements in this list

listIterator

public java.util.ListIterator listIterator()
Returns a list iterator of the elements in this list in proper sequnce. This iterator does not support modifying the list, and represents a snapshot of the contents of this list at the time the iterator is fetched.
Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class java.util.AbstractList

listIterator

public java.util.ListIterator listIterator(int index)
Returns a list iterator of the elements in this list in proper sequence, starting at the given index. This iterator does not support modifying the list, and represents a snapshot of the contents of this list at the time the iterator is fetched.
Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class java.util.AbstractList
Parameters:
index - the index to start from
Returns:
a list iterator over the elements of this list

subList

public java.util.List subList(int startIndex,
                              int endIndex)
This operation is not supported by this list implementation.
Specified by:
subList in interface java.util.List
Overrides:
subList in class java.util.AbstractList

toString

public java.lang.String toString()
Fetch a visible representation of this object.
Overrides:
toString in class java.util.AbstractCollection

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


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