org.norther.tammi.acorn.util
Class WeakArrayList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by org.norther.tammi.acorn.util.WeakArrayList
All Implemented Interfaces:
Iterable, Collection, List

public class WeakArrayList
extends AbstractList
implements List

A variation of ArrayAsList storing internally its elements as weak references.

Author:
Ilkka Priha

Nested Class Summary
protected static class WeakArrayList.ReferenceIterator
          An inner class for iterators.
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
WeakArrayList()
          Constructs an empty collection.
WeakArrayList(Collection c)
          Constructs a new collection.
 
Method Summary
 void add(int index, Object item)
           
 boolean add(Object item)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void clear()
           
 boolean contains(Object item)
           
 boolean containsAll(Collection c)
           
 boolean equals(Object o)
           
 Object get(int index)
           
protected  ArrayAsList getArrayAsList()
          Gets the list adaptee.
 int hashCode()
           
 int indexOf(Object item)
           
protected static int indexOf(Object item, WeakReference[] array, int offset, int n)
          A static index method without synchronization.
 Iterator iterator()
           
 int lastIndexOf(Object item)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 Object remove(int index)
           
 boolean remove(Object item)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 Object set(int index, Object item)
           
 int size()
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 
Methods inherited from class java.util.AbstractList
removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
isEmpty, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
isEmpty, subList
 

Constructor Detail

WeakArrayList

public WeakArrayList()
Constructs an empty collection.


WeakArrayList

public WeakArrayList(Collection c)
Constructs a new collection.

Parameters:
c - a collection to wrap.
Method Detail

indexOf

protected static int indexOf(Object item,
                             WeakReference[] array,
                             int offset,
                             int n)
A static index method without synchronization.

Parameters:
item - the item to search.
array - the array of items.
offset - the start index.
n - the number of items to iterate.
Returns:
the index of the found item or -1.

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class AbstractList

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class AbstractList

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface List
Specified by:
size in class AbstractCollection

contains

public boolean contains(Object item)
Specified by:
contains in interface Collection
Specified by:
contains in interface List
Overrides:
contains in class AbstractCollection

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List
Overrides:
containsAll in class AbstractCollection

indexOf

public int indexOf(Object item)
Specified by:
indexOf in interface List
Overrides:
indexOf in class AbstractList

lastIndexOf

public int lastIndexOf(Object item)
Specified by:
lastIndexOf in interface List
Overrides:
lastIndexOf in class AbstractList

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class AbstractCollection

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class AbstractCollection

get

public Object get(int index)
Specified by:
get in interface List
Specified by:
get in class AbstractList

set

public Object set(int index,
                  Object item)
Specified by:
set in interface List
Overrides:
set in class AbstractList

add

public boolean add(Object item)
Specified by:
add in interface Collection
Specified by:
add in interface List
Overrides:
add in class AbstractList

add

public void add(int index,
                Object item)
Specified by:
add in interface List
Overrides:
add in class AbstractList

remove

public Object remove(int index)
Specified by:
remove in interface List
Overrides:
remove in class AbstractList

remove

public boolean remove(Object item)
Specified by:
remove in interface Collection
Specified by:
remove in interface List
Overrides:
remove in class AbstractCollection

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface List
Overrides:
clear in class AbstractList

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
Overrides:
addAll in class AbstractCollection

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List
Overrides:
addAll in class AbstractList

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List
Overrides:
removeAll in class AbstractCollection

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List
Overrides:
retainAll in class AbstractCollection

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List
Overrides:
iterator in class AbstractList

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List
Overrides:
listIterator in class AbstractList

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List
Overrides:
listIterator in class AbstractList

getArrayAsList

protected ArrayAsList getArrayAsList()
Gets the list adaptee.

Returns:
the wrapped list.


Copyright © 2004 The Norther Organization. All rights reserved.