org.multiverse.transactional.collections
Class TransactionalArrayList<E>

java.lang.Object
  extended by org.multiverse.transactional.collections.TransactionalArrayList<E>
Type Parameters:
E -
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, TransactionalCollection<E>, TransactionalList<E>

public final class TransactionalArrayList<E>
extends java.lang.Object
implements TransactionalList<E>

A TransactionalList based on a (transactional) array. It is the transactional version of the ArrayList.

Author:
Peter Veentjer.

Constructor Summary
TransactionalArrayList()
          Creates a new TransactionalArrayList with capacity 10.
TransactionalArrayList(java.util.Collection<? extends E> items)
          Creates a new TransactionalArrayList that contains the items.
TransactionalArrayList(E... items)
          Creates a new TransactionalArrayList that contains the items.
TransactionalArrayList(int capacity)
          Creates a new TransactionalArrayList with the provided capacity.
 
Method Summary
 boolean add(E e)
           
 void add(int index, E element)
           
 boolean addAll(java.util.Collection<? extends E> c)
           
 boolean addAll(int index, java.util.Collection<? extends E> c)
           
 int atomicSize()
          Returns the current size of the TransactionalCollection.
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 boolean equals(java.lang.Object thatObj)
           
 E get(int index)
           
 int hashCode()
           
 int indexOf(java.lang.Object o)
           
 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator<E> listIterator()
           
 java.util.ListIterator<E> listIterator(int index)
           
 E remove(int index)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 E set(int index, E element)
           
 int size()
           
 java.util.List<E> subList(int fromIndex, int toIndex)
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransactionalArrayList

public TransactionalArrayList()
Creates a new TransactionalArrayList with capacity 10. This is the same initial capacity as ArrayList.ArrayList().


TransactionalArrayList

public TransactionalArrayList(E... items)
Creates a new TransactionalArrayList that contains the items.

Parameters:
items - the items to add to this List.
Throws:
java.lang.NullPointerException - if items is null.

TransactionalArrayList

public TransactionalArrayList(java.util.Collection<? extends E> items)
Creates a new TransactionalArrayList that contains the items.

Parameters:
items - the items to add to this List.
Throws:
java.lang.NullPointerException - if items is null.

TransactionalArrayList

public TransactionalArrayList(int capacity)
Creates a new TransactionalArrayList with the provided capacity.

Parameters:
capacity - the initial capacity of the TransactionalArrayList.
Method Detail

size

public int size()
Specified by:
size in interface java.util.Collection<E>
Specified by:
size in interface java.util.List<E>
Specified by:
size in interface TransactionalCollection<E>

atomicSize

public int atomicSize()
Description copied from interface: TransactionalCollection
Returns the current size of the TransactionalCollection. The big difference between the normal TransactionalCollection.size() method is that this one returns the actual size of this map and doesn't look at the current transaction. So you could see changes made by other threads.

Specified by:
atomicSize in interface TransactionalCollection<E>
Returns:
the current size of the TransactionalMap.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E>
Specified by:
isEmpty in interface java.util.List<E>
Specified by:
isEmpty in interface TransactionalCollection<E>

add

public boolean add(E e)
Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.List<E>
Specified by:
add in interface TransactionalCollection<E>

get

public E get(int index)
Specified by:
get in interface java.util.List<E>
Specified by:
get in interface TransactionalList<E>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<E>
Specified by:
contains in interface java.util.List<E>
Specified by:
contains in interface TransactionalCollection<E>

indexOf

public int indexOf(java.lang.Object o)
Specified by:
indexOf in interface java.util.List<E>
Specified by:
indexOf in interface TransactionalList<E>

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Specified by:
lastIndexOf in interface java.util.List<E>
Specified by:
lastIndexOf in interface TransactionalList<E>

set

public E set(int index,
             E element)
Specified by:
set in interface java.util.List<E>
Specified by:
set in interface TransactionalList<E>

addAll

public boolean addAll(java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.Collection<E>
Specified by:
addAll in interface java.util.List<E>
Specified by:
addAll in interface TransactionalCollection<E>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E>
Specified by:
clear in interface java.util.List<E>
Specified by:
clear in interface TransactionalCollection<E>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.List<E>
Specified by:
toArray in interface TransactionalCollection<E>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.List<E>
Specified by:
toArray in interface TransactionalCollection<E>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<E>
Specified by:
containsAll in interface java.util.List<E>
Specified by:
containsAll in interface TransactionalCollection<E>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<E>
Specified by:
remove in interface java.util.List<E>
Specified by:
remove in interface TransactionalCollection<E>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<E>
Specified by:
removeAll in interface java.util.List<E>
Specified by:
removeAll in interface TransactionalCollection<E>

remove

public E remove(int index)
Specified by:
remove in interface java.util.List<E>
Specified by:
remove in interface TransactionalList<E>

add

public void add(int index,
                E element)
Specified by:
add in interface java.util.List<E>
Specified by:
add in interface TransactionalList<E>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.List<E>
Specified by:
addAll in interface TransactionalList<E>

listIterator

public java.util.ListIterator<E> listIterator()
Specified by:
listIterator in interface java.util.List<E>
Specified by:
listIterator in interface TransactionalList<E>

listIterator

public java.util.ListIterator<E> listIterator(int index)
Specified by:
listIterator in interface java.util.List<E>
Specified by:
listIterator in interface TransactionalList<E>

subList

public java.util.List<E> subList(int fromIndex,
                                 int toIndex)
Specified by:
subList in interface java.util.List<E>
Specified by:
subList in interface TransactionalList<E>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.List<E>
Specified by:
iterator in interface TransactionalCollection<E>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<E>
Specified by:
retainAll in interface java.util.List<E>
Specified by:
retainAll in interface TransactionalCollection<E>

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<E>
Specified by:
hashCode in interface java.util.List<E>
Specified by:
hashCode in interface TransactionalCollection<E>
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object thatObj)
Specified by:
equals in interface java.util.Collection<E>
Specified by:
equals in interface java.util.List<E>
Specified by:
equals in interface TransactionalCollection<E>
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Specified by:
toString in interface TransactionalCollection<E>
Overrides:
toString in class java.lang.Object


Copyright © 2008-2010 Multiverse. All Rights Reserved.