|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.util.OrderedSet<K>
public class OrderedSet<K>
OrderedSet
provides a Set where values can also be retrieved in
the order they were added
Nested Class Summary | |
---|---|
static interface |
OrderedSet.ChangeListener
ChangeListener interface |
static class |
OrderedSet.ChangeListenerAdapter
ChangeListener adapter |
Field Summary | |
---|---|
protected static int |
ENTRY_ADDED
|
protected static int |
ENTRY_REMOVED
|
Constructor Summary | |
---|---|
OrderedSet()
Constructor |
|
OrderedSet(boolean retainOriginalValue)
Construtor |
|
OrderedSet(java.util.Collection<? extends K> c)
Construtor |
|
OrderedSet(java.util.Collection<? extends K> c,
boolean retainOriginalValue)
Construtor |
|
OrderedSet(K[] a)
Construtor |
|
OrderedSet(K[] a,
boolean retainOriginalValue)
Construtor |
|
OrderedSet(OrderedSet<K> os)
Copy Construtor |
Method Summary | ||
---|---|---|
protected void |
_add(int ndx,
K obj)
Adds the Object at the specified index |
|
protected boolean |
_remove(java.lang.Object obj)
Removes the specified object from this set |
|
protected boolean |
_remove(java.lang.Object obj,
java.util.Iterator i)
Removes the specified object referenced by the specified iterator from this set |
|
void |
add(int ndx,
K obj)
Adds the Object at the specified index |
|
boolean |
add(K obj)
Adds the Object to the end of the list |
|
boolean |
addAll(java.util.Collection<? extends K> c)
Adds all Objects in the specified Collection to this set |
|
boolean |
addAll(int ndx,
java.util.Collection<? extends K> c)
Throws an UnsupportedOperationException |
|
boolean |
addAll(K[] a)
Adds all Objects in the specified array to this set |
|
void |
addChangeListener(OrderedSet.ChangeListener cl)
Adds a change listener to this OrderedSet |
|
void |
clear()
Clears all Objects from this set |
|
java.lang.Object |
clone()
Returns a clone of this OrderedSet |
|
boolean |
contains(java.lang.Object obj)
Returns true if this set contains the specified Object |
|
boolean |
containsAll(java.util.Collection<?> c)
Returns true if this set contains all items specified in the Collection |
|
boolean |
equals(java.lang.Object other)
Returns true if this set is equivalent to the specified Object |
|
K |
get(int ndx)
Gets the Objects at the specified index |
|
protected java.util.List<K> |
getBackingList()
Gets the ordered backing list for this OrderedSet |
|
protected java.util.List<OrderedSet.ChangeListener> |
getChangeListeners(boolean create)
Gets a list of change listeners |
|
protected java.util.List<K> |
getList()
Gets the ordered backing list for this OrderedSet. |
|
boolean |
getRetainOriginalValue()
Returns true if original added entries should be retained if a duplicate entry is subsequently added. |
|
protected boolean |
hasChangeListeners()
Returns true if any change listeners have been registered |
|
int |
hashCode()
Returns the hashcode for this set |
|
int |
indexOf(java.lang.Object obj)
Returns the index of the specified Object in this set |
|
boolean |
isEmpty()
Returns true if this set is empty |
|
java.util.Iterator<K> |
iterator()
Returns an ordered Iterator over the elements in this set. |
|
int |
lastIndexOf(java.lang.Object obj)
Returns the last index of the specified Object in this set. |
|
java.util.ListIterator<K> |
listIterator()
Returns a ListIterator over this set |
|
java.util.ListIterator<K> |
listIterator(int ndx)
Returns a ListIterator over this set. |
|
protected void |
notifyChangeListeners(int action,
java.lang.Object obj)
Notifies all change listeners of a change to this OrderedSet |
|
void |
printContents()
Prints the contents of this set (for debug/testing purposes) |
|
K |
remove(int ndx)
Throws UnsupportedOperationException |
|
boolean |
remove(java.lang.Object obj)
Removes the specified object from this set |
|
boolean |
removeAll(java.util.Collection<?> c)
Remove all Objects contained in the specified Collection from this set |
|
void |
removeChangeListener(OrderedSet.ChangeListener cl)
Removes a change listener to this OrderedSet |
|
boolean |
retainAll(java.util.Collection<?> c)
Removes all Object from this set that are not reference in the specified Collection |
|
K |
set(int ndx,
K obj)
Throws an UnsupportedOperationException |
|
void |
setRetainOriginalValue(boolean state)
Sets the retain-original state for this OrderedSet if duplicate entries are added. |
|
int |
size()
Returns the number of elements in this set |
|
java.util.List<K> |
subList(int fromIndex,
int toIndex)
Thows UnsupportedOperationException |
|
java.lang.Object[] |
toArray()
Returns an array of Object elements in this set |
|
|
toArray(K[] a)
Returns an array of Object elements in this set |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int ENTRY_ADDED
protected static final int ENTRY_REMOVED
Constructor Detail |
---|
public OrderedSet()
public OrderedSet(boolean retainOriginalValue)
retainOriginalValue
- True to ignore duplicate entries, false overwrite existing entries
with any newly added duplicates.public OrderedSet(java.util.Collection<? extends K> c, boolean retainOriginalValue)
c
- Collection of Objects used to initialize this set.retainOriginalValue
- True to ignore duplicate entries, false overwrite existing entries
with any newly added duplicates.public OrderedSet(java.util.Collection<? extends K> c)
c
- Collection of Objects used to initialize this set.public OrderedSet(K[] a, boolean retainOriginalValue)
a
- Array of Objects used to initialize this set.retainOriginalValue
- True to ignore duplicate entries, false overwrite existing entries
with any newly added duplicates.public OrderedSet(K[] a)
a
- Array of Objects used to initialize this set.public OrderedSet(OrderedSet<K> os)
os
- Other OrderedSet used to initialize this setMethod Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
protected java.util.List<OrderedSet.ChangeListener> getChangeListeners(boolean create)
create
- True to create an empty list if no change listeners have been added
protected boolean hasChangeListeners()
public void addChangeListener(OrderedSet.ChangeListener cl)
cl
- The change listener to addpublic void removeChangeListener(OrderedSet.ChangeListener cl)
cl
- The change listener to removeprotected void notifyChangeListeners(int action, java.lang.Object obj)
action
- The change actionobj
- The Object changedprotected java.util.List<K> getBackingList()
protected java.util.List<K> getList()
public boolean getRetainOriginalValue()
public void setRetainOriginalValue(boolean state)
state
- True to retain original added entriespublic K get(int ndx)
get
in interface java.util.List<K>
ndx
- The index
public K set(int ndx, K obj)
set
in interface java.util.List<K>
ndx
- The indexobj
- The Object to set
java.lang.UnsupportedOperationException
- alwaysprotected void _add(int ndx, K obj)
ndx
- The indexobj
- The Object to addpublic boolean add(K obj)
add
in interface java.util.Collection<K>
add
in interface java.util.List<K>
add
in interface java.util.Set<K>
obj
- The Object to addpublic boolean addAll(java.util.Collection<? extends K> c)
addAll
in interface java.util.Collection<K>
addAll
in interface java.util.List<K>
addAll
in interface java.util.Set<K>
c
- The Collection
public boolean addAll(K[] a)
a
- The array
public void add(int ndx, K obj)
add
in interface java.util.List<K>
ndx
- The indexobj
- The Object to addpublic boolean addAll(int ndx, java.util.Collection<? extends K> c)
addAll
in interface java.util.List<K>
ndx
- The indexc
- The Collection
java.lang.UnsupportedOperationException
- alwayspublic boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection<K>
contains
in interface java.util.List<K>
contains
in interface java.util.Set<K>
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<K>
containsAll
in interface java.util.List<K>
containsAll
in interface java.util.Set<K>
public boolean equals(java.lang.Object other)
equals
in interface java.util.Collection<K>
equals
in interface java.util.List<K>
equals
in interface java.util.Set<K>
equals
in class java.lang.Object
other
- The other Object
public int hashCode()
hashCode
in interface java.util.Collection<K>
hashCode
in interface java.util.List<K>
hashCode
in interface java.util.Set<K>
hashCode
in class java.lang.Object
protected boolean _remove(java.lang.Object obj)
obj
- The Object to remove
protected boolean _remove(java.lang.Object obj, java.util.Iterator i)
obj
- The Object to removei
- The Iterator which references the Objet to remove
public K remove(int ndx)
remove
in interface java.util.List<K>
ndx
- The object index to remove
java.lang.UnsupportedOperationException
- alwayspublic boolean remove(java.lang.Object obj)
remove
in interface java.util.Collection<K>
remove
in interface java.util.List<K>
remove
in interface java.util.Set<K>
obj
- THe Object to remove
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<K>
removeAll
in interface java.util.List<K>
removeAll
in interface java.util.Set<K>
c
- The Collection containing the list of Objects to remove from this set
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<K>
retainAll
in interface java.util.List<K>
retainAll
in interface java.util.Set<K>
c
- The Collection of Objects to keep
public void clear()
clear
in interface java.util.Collection<K>
clear
in interface java.util.List<K>
clear
in interface java.util.Set<K>
public int size()
size
in interface java.util.Collection<K>
size
in interface java.util.List<K>
size
in interface java.util.Set<K>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<K>
isEmpty
in interface java.util.List<K>
isEmpty
in interface java.util.Set<K>
public int indexOf(java.lang.Object obj)
indexOf
in interface java.util.List<K>
obj
- The Object for which the index is returned
public int lastIndexOf(java.lang.Object obj)
lastIndexOf
in interface java.util.List<K>
obj
- The Object for which the index is returned
public java.util.Iterator<K> iterator()
iterator
in interface java.lang.Iterable<K>
iterator
in interface java.util.Collection<K>
iterator
in interface java.util.List<K>
iterator
in interface java.util.Set<K>
public java.util.ListIterator<K> listIterator()
listIterator
in interface java.util.List<K>
public java.util.ListIterator<K> listIterator(int ndx)
listIterator
in interface java.util.List<K>
ndx
- The starting index.
public java.util.List<K> subList(int fromIndex, int toIndex)
subList
in interface java.util.List<K>
fromIndex
- The 'from' index.toIndex
- The 'to' index.
java.lang.UnsupportedOperationException
- alwayspublic java.lang.Object[] toArray()
toArray
in interface java.util.Collection<K>
toArray
in interface java.util.List<K>
toArray
in interface java.util.Set<K>
public <K> K[] toArray(K[] a)
toArray
in interface java.util.Collection<K>
toArray
in interface java.util.List<K>
toArray
in interface java.util.Set<K>
a
- The array into which the elements are copied
public void printContents()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |