public final class PopularityList<E> extends TransformedList<E,E>
EventList
that shows the unique elements from its source
EventList
ordered by the frequency of their appearance.
This EventList
supports all write operations.
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: | reads: O(log N), writes O(log N) |
Memory: | 196 bytes per element |
Unit Tests: | N/A |
Issues: | 104 |
source
publisher, readWriteLock, updates
Constructor and Description |
---|
PopularityList(EventList<E> source)
Creates a new
PopularityList that provides frequency-ranking
for the specified EventList . |
PopularityList(EventList<E> source,
java.util.Comparator<E> uniqueComparator)
Creates a new
PopularityList that provides frequency-ranking
for the specified EventList . |
Modifier and Type | Method and Description |
---|---|
static <E extends java.lang.Comparable<? super E>> |
create(EventList<E> source)
Creates a new
PopularityList that provides frequency-ranking
for the specified EventList . |
void |
dispose()
Releases the resources consumed by this
TransformedList so that it
may eventually be garbage collected. |
protected boolean |
isWritable()
Gets whether the source
EventList is writable via this API. |
void |
listChanged(ListEvent<E> listChanges)
When the underlying list changes, this notification allows the
object to repaint itself or update itself as necessary.
|
add, addAll, clear, get, getSourceIndex, remove, removeAll, retainAll, set, size
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString
public PopularityList(EventList<E> source)
PopularityList
that provides frequency-ranking
for the specified EventList
. All elements of the source EventList
must implement Comparable
.
Usage of factory method create(EventList)
is preferable.
public PopularityList(EventList<E> source, java.util.Comparator<E> uniqueComparator)
PopularityList
that provides frequency-ranking
for the specified EventList
.uniqueComparator
- Comparator
used to determine equalitypublic static <E extends java.lang.Comparable<? super E>> PopularityList<E> create(EventList<E> source)
PopularityList
that provides frequency-ranking
for the specified EventList
. All elements of the source EventList
must implement Comparable
.protected boolean isWritable()
EventList
is writable via this API.
Extending classes must override this method in order to make themselves writable.
isWritable
in class TransformedList<E,E>
public void listChanged(ListEvent<E> listChanges)
It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.
listChanged
in interface ListEventListener<E>
listChanged
in class TransformedList<E,E>
listChanges
- a ListEvent
describing the changes to the listpublic void dispose()
TransformedList
so that it
may eventually be garbage collected.
A TransformedList
will be garbage collected without a call to
TransformedList.dispose()
, but not before its source EventList
is garbage
collected. By calling TransformedList.dispose()
, you allow the TransformedList
to be garbage collected before its source EventList
. This is
necessary for situations where a TransformedList
is short-lived but
its source EventList
is long-lived.
Warning: It is an error
to call any method on a TransformedList
after it has been disposed.
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by mockbuild at 2017-02-10 17:48