com.purpletech.util
Class IndexedList
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.ArrayList
|
+--com.purpletech.util.IndexedList
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable
- public class IndexedList
- extends java.util.ArrayList
A List that keeps an index of its contents. Sort of like a sorted
set or a map or an EntryList.
CAN'T implement both Map and List. Why? Because remove() has two
different return types... IndexedList.java:5: The method boolean
remove(java.lang.Object) declared in class
java.util.AbstractCollection cannot override the method of the same
signature declared in interface java.util.Map. They must have the
same return type.
- See Also:
- Serialized Form
| Fields inherited from class java.util.AbstractList |
modCount |
|
Method Summary |
void |
add(int index,
java.lang.Object obj)
|
boolean |
add(java.lang.Object obj)
|
boolean |
addAll(java.util.Collection c)
|
void |
clear()
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
java.util.Set |
entrySet()
|
java.lang.Object |
get(java.lang.Object key)
|
java.util.Map |
getIndex()
|
protected void |
index(java.lang.Object obj)
|
java.util.Set |
keySet()
|
static void |
main(java.lang.String[] args)
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
|
void |
putAll(java.util.Map t)
|
java.lang.Object |
remove(int i)
|
java.lang.Object |
set(int i,
java.lang.Object x)
|
protected void |
unindex(java.lang.Object obj)
|
java.util.Collection |
values()
|
| Methods inherited from class java.util.ArrayList |
addAll, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, removeRange, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
containsAll, remove, removeAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList |
allowMultiple
public boolean allowMultiple
IndexedList
public IndexedList(IndexedList.Indexer indexer)
- Parameters:
indexer - an object that will extract the key from any object you add
getIndex
public java.util.Map getIndex()
index
protected void index(java.lang.Object obj)
unindex
protected void unindex(java.lang.Object obj)
add
public boolean add(java.lang.Object obj)
- Specified by:
add in interface java.util.List- Overrides:
add in class java.util.ArrayList
add
public void add(int index,
java.lang.Object obj)
- Specified by:
add in interface java.util.List- Overrides:
add in class java.util.ArrayList
addAll
public boolean addAll(java.util.Collection c)
- Specified by:
addAll in interface java.util.List- Overrides:
addAll in class java.util.ArrayList
clear
public void clear()
- Specified by:
clear in interface java.util.List- Overrides:
clear in class java.util.ArrayList
get
public java.lang.Object get(java.lang.Object key)
remove
public java.lang.Object remove(int i)
- Specified by:
remove in interface java.util.List- Overrides:
remove in class java.util.ArrayList
set
public java.lang.Object set(int i,
java.lang.Object x)
- Specified by:
set in interface java.util.List- Overrides:
set in class java.util.ArrayList
containsKey
public boolean containsKey(java.lang.Object key)
containsValue
public boolean containsValue(java.lang.Object value)
put
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
putAll
public void putAll(java.util.Map t)
keySet
public java.util.Set keySet()
values
public java.util.Collection values()
entrySet
public java.util.Set entrySet()
main
public static void main(java.lang.String[] args)