org.progeeks.util
Class ReversedList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by org.progeeks.util.ReversedList
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.List

public class ReversedList
extends java.util.AbstractList

A lazy reversed view of a delegate List.

Version:
$Revision: 1.1 $
Author:
Ray A. Conner

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ReversedList()
           
ReversedList(java.util.List delegate)
           
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object element)
           
 void clear()
           
 boolean contains(java.lang.Object element)
           
 boolean containsAll(java.util.Collection collection)
           
 java.lang.Object get(int index)
           
protected  java.util.List getDelegate()
           
 int indexOf(java.lang.Object element)
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 int lastIndexOf(java.lang.Object element)
           
 java.util.ListIterator listIterator(int index)
           
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object element)
           
 boolean removeAll(java.util.Collection collection)
           
 boolean retainAll(java.util.Collection collection)
           
 java.lang.Object set(int index, java.lang.Object element)
           
protected  void setDelegate(java.util.List delegate)
           
 int size()
           
 java.util.List subList(int fromIndex, int toIndex)
           
protected  int toIndex(int index)
          Converts from a reverse index to a delegate index, or vice versa.
 
Methods inherited from class java.util.AbstractList
addAll, equals, hashCode, listIterator, removeRange
 
Methods inherited from class java.util.AbstractCollection
addAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, toArray, toArray
 

Constructor Detail

ReversedList

public ReversedList()

ReversedList

public ReversedList(java.util.List delegate)
Method Detail

getDelegate

protected java.util.List getDelegate()

setDelegate

protected void setDelegate(java.util.List delegate)

toIndex

protected final int toIndex(int index)
Converts from a reverse index to a delegate index, or vice versa. Reflection is wonderfully symmetrical.


size

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

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.List
Overrides:
isEmpty in class java.util.AbstractCollection

clear

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

contains

public boolean contains(java.lang.Object element)
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.List
Overrides:
contains in class java.util.AbstractCollection

containsAll

public boolean containsAll(java.util.Collection collection)
Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.List
Overrides:
containsAll in class java.util.AbstractCollection

add

public boolean add(java.lang.Object element)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.AbstractList

remove

public boolean remove(java.lang.Object element)
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.AbstractCollection

removeAll

public boolean removeAll(java.util.Collection collection)
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 collection)
Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.List
Overrides:
retainAll in class java.util.AbstractCollection

iterator

public java.util.Iterator iterator()
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

get

public java.lang.Object get(int index)
Specified by:
get in interface java.util.List
Specified by:
get in class java.util.AbstractList

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Specified by:
set in interface java.util.List
Overrides:
set in class java.util.AbstractList

indexOf

public int indexOf(java.lang.Object element)
Specified by:
indexOf in interface java.util.List
Overrides:
indexOf in class java.util.AbstractList

lastIndexOf

public int lastIndexOf(java.lang.Object element)
Specified by:
lastIndexOf in interface java.util.List
Overrides:
lastIndexOf in class java.util.AbstractList

add

public void add(int index,
                java.lang.Object element)
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.AbstractList

remove

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

subList

public java.util.List subList(int fromIndex,
                              int toIndex)
Specified by:
subList in interface java.util.List
Overrides:
subList in class java.util.AbstractList

listIterator

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


Copyright © 2002-2003 Paul Speed. All Rights Reserved.