|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.nettgryppa.util.InfiniteList<E>
public class InfiniteList<E>
This class is meant to simulate a list of infinite (and optionally bi-infinite) length. All positive indices
are valid but will default to null. This list can also be bi-infinite, in which case all
negative indices are also valid. This class is also useful for sparse lists as it is backed by a SortedMap
Copyright 2006 Gregory Rubin grrubin@gmail.com
Permission is given to use, modify, and or distribute this code so long as this message remains attached
| Constructor Summary | |
|---|---|
InfiniteList()
Constructs an empty list with allowNegative set to false. |
|
InfiniteList(boolean allowNegative)
Constructs an empty list. |
|
InfiniteList(InfiniteList<E> obj)
Copy constructor |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E element)
|
|
void |
add(int index,
E element)
|
|
boolean |
addAll(Collection<? extends E> c)
|
|
boolean |
addAll(int index,
Collection<? extends E> c)
|
|
boolean |
allowsNegative()
Does this specific instance allow negative indices |
|
void |
clear()
|
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> o)
|
|
boolean |
equals(Object o)
Acts as expected if other object is an InfiniteList. |
|
E |
get(int index)
|
|
int |
hashCode()
|
|
int |
indexOf(Object o)
WARNING! DO NOT USE THIS TO DETERMINE IF THE LIST CONTAINS AN ELEMENT AS -1 IS A VALID RESPONSE! USE contains(Object o)
If o is null then returns min() - 1 |
|
Set<Integer> |
indexSet()
All indices with non-null values in ascending order |
|
boolean |
isEmpty()
|
|
Iterator<E> |
iterator()
|
|
int |
lastIndexOf(Object o)
WARNING! DO NOT USE THIS TO DETERMINE IF THE LIST CONTAINS AN ELEMENT AS -1 IS A VALID RESPONSE! USE contains(Object o)
WARNING! THIS IS A SLOW IMPLEMENTATION
If o is null then returns max() + 1 |
|
ListIterator<E> |
listIterator()
|
|
ListIterator<E> |
listIterator(int index)
|
|
int |
load()
|
|
int |
max()
Maximum assigned index |
|
int |
min()
Minimum assigned index |
|
E |
remove(int index)
|
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
boolean |
retainAll(Collection<?> c)
|
|
E |
set(int index,
E element)
|
|
int |
size()
|
|
InfiniteList<E> |
subList(int fromIndex,
int toIndex)
|
|
Object[] |
toArray()
NOTE: While order is guaranteed, indices are not guarenteed to be identical unless all are non-negative |
|
|
toArray(T[] a)
NOTE: While order is guaranteed, indices are not guarenteed to be identical unless all are non-negative |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InfiniteList()
allowNegative set to false.
public InfiniteList(boolean allowNegative)
public InfiniteList(InfiniteList<E> obj)
| Method Detail |
|---|
public boolean allowsNegative()
public int size()
size in interface Collection<E>size in interface List<E>public int max()
public int min()
public int load()
public boolean add(E element)
add in interface Collection<E>add in interface List<E>
public void add(int index,
E element)
add in interface List<E>public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in interface List<E>
public boolean addAll(int index,
Collection<? extends E> c)
addAll in interface List<E>public void clear()
clear in interface Collection<E>clear in interface List<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface List<E>public boolean containsAll(Collection<?> o)
containsAll in interface Collection<E>containsAll in interface List<E>public Set<Integer> indexSet()
public boolean equals(Object o)
infiniteList.equals(o) == o.equals(infiniteList) An example of where this will
break is any list that contains nulls on either end.
equals in interface Collection<E>equals in interface List<E>equals in class Objectpublic E get(int index)
get in interface List<E>public int hashCode()
hashCode in interface Collection<E>hashCode in interface List<E>hashCode in class Objectpublic int indexOf(Object o)
contains(Object o)
If o is null then returns min() - 1
indexOf in interface List<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface List<E>public int lastIndexOf(Object o)
contains(Object o)
WARNING! THIS IS A SLOW IMPLEMENTATION
If o is null then returns max() + 1
lastIndexOf in interface List<E>public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface List<E>public ListIterator<E> listIterator()
listIterator in interface List<E>public ListIterator<E> listIterator(int index)
listIterator in interface List<E>public E remove(int index)
remove in interface List<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface List<E>
public E set(int index,
E element)
set in interface List<E>
public InfiniteList<E> subList(int fromIndex,
int toIndex)
subList in interface List<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in interface List<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in interface List<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface List<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in interface List<E>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||