ca.odell.glazedlists
Class UniqueList<E>
- EventListener, EventList<E>, List, ListEventListener<E>
public final class UniqueList<E>
An
EventList
that shows the unique elements from its source
EventList
. For example, the source list {A, A, B, C, C, C, D} would
be simplified to {A, B, C, D} by this UniqueList.
Warning: This class breaks
the contract required by
List
. See
EventList
for an example.
Warning: This class is
thread ready but not thread safe. See
EventList
for an example
of thread safe code.
EventList Overview |
Writable: | yes |
Concurrency: | thread ready, not thread safe |
Performance: | |
Memory: | N/A |
Unit Tests: | N/A |
Issues: |
27
34
35
45
46
55
58
114
|
UniqueList(EventList source) - Creates a
UniqueList that determines uniqueness via the
Comparable interface.
|
UniqueList(EventList source, E> comparator) - Creates a
UniqueList that determines uniqueness using the
specified Comparator .
|
void | dispose() -
|
static | extends Comparable super E>> UniqueList create(EventList source) - Creates a
UniqueList that determines uniqueness via the
Comparable interface.
|
List | getAll(E value) - Returns a List of all original elements represented by the given
value within this UniqueList .
|
List | getAll(int index) - Returns a List of all original elements represented by the value at the
given
index within this UniqueList .
|
int | getCount(E value) - Returns the number of duplicates of the specified value.
|
int | getCount(int index) - Returns the number of duplicates of the value found at the specified index.
|
protected int | getSourceIndex(int index) -
|
int | indexOf(Object element) - Returns the index in this list of the first occurrence of the specified
element , or -1 if this list does not contain this
element .
|
protected boolean | isWritable() -
|
void | listChanged(ListEvent listChanges) -
|
E | remove(int index) -
|
E | set(int index, E value) -
|
void | setComparator(E> comparator) - Change the
Comparator which determines the unique elements
of this List.
|
int | size() -
|
add , addAll , clear , dispose , get , getSourceIndex , isWritable , listChanged , remove , removeAll , retainAll , set , size |
T[] toArray , add , add , addAll , addAll , addListEventListener , clear , contains , containsAll , equals , get , getPublisher , getReadWriteLock , hashCode , indexOf , isEmpty , iterator , lastIndexOf , listIterator , listIterator , remove , remove , removeAll , removeListEventListener , retainAll , set , size , subList , toArray , toString |
UniqueList
public UniqueList(EventList source)
Creates a
UniqueList
that determines uniqueness via the
Comparable
interface. All elements of the source
EventList
must implement
Comparable
.
Usage of factory method
create(EventList)
is preferable.
source
- the EventList
containing duplicates to remove
UniqueList
public UniqueList(EventList source,
E> comparator)
Creates a
UniqueList
that determines uniqueness using the
specified
Comparator
.
source
- the EventList
containing duplicates to removecomparator
- the Comparator
used to determine equality
extends Comparable super E>> UniqueList create
public static > UniqueList create(EventList source)
Creates a
UniqueList
that determines uniqueness via the
Comparable
interface. All elements of the source
EventList
must implement
Comparable
.
source
- the EventList
containing duplicates to remove
getAll
public List getAll(E value)
Returns a List of all original elements represented by the given
value
within this
UniqueList
.
getAll
public List getAll(int index)
Returns a List of all original elements represented by the value at the
given
index
within this
UniqueList
.
getCount
public int getCount(E value)
Returns the number of duplicates of the specified value.
getCount
public int getCount(int index)
Returns the number of duplicates of the value found at the specified index.
indexOf
public int indexOf(Object element)
Returns the index in this list of the first occurrence of the specified
element
, or -1 if this list does not contain this
element
. More formally, returns the lowest index
i
such that
uniqueListComparator.compare(get(i), element) == 0,
or -1 if there is no such index.
Note: This is a departure from the contract for
List.indexOf
since it does not guarantee that
element.equals(get(i)) where i
is a positive index returned from this method.
- indexOf in interface AbstractEventList<E>
element
- the element to search for.
- the index in this list of the first occurrence of the specified
element, or -1 if this list does not contain this element
setComparator
public void setComparator(E> comparator)
Change the Comparator
which determines the unique elements
of this List.
comparator
- the Comparator
used to determine groupings;
null will be treated as GlazedLists.comparableComparator()
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by pbuilder at 2009-07-14 22:05