/** * Private constructor is used as a Java-language hack to allow us to save * a reference to the specified {@link UniqueList}. */ private PopularityList(UniqueList<E> uniqueList) { super(new SortedList<E>(uniqueList, new PopularityComparator<E>(uniqueList))); this.uniqueList = uniqueList; // listen for changes to the source list source.addListEventListener(this); }
public InitializationData(EventList<E> sourceElements, Format<E> format, ExpansionModel<E> expansionModel) { this.format = format; this.expansionModel = expansionModel; this.sourceNodes = new FunctionList<E,Node<E>>(sourceElements, new ElementToTreeNodeFunction<E>(format, expansionModel), NO_OP_FUNCTION); this.nodeComparator = comparatorToNodeComparator(format); this.sortedList = new SortedList<Node<E>>(sourceNodes, nodeComparator); }
/** {@inheritDoc} */ @Override public boolean add(E value) { beforeWriteOperation(); try { return delegate.add(value); } finally { afterWriteOperation(); } }
SortedList<Row> sorted = new SortedList<Row>( list, new Comparator<Row>() { assertEquals( 3, sorted.size() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 2, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 2 ).get( "stilton" )).getPrice() ); assertEquals( 2, sorted.size() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 2, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 3, sorted.size() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 2, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 2 ).get( "stilton" )).getPrice() ); assertEquals( 2, sorted.size() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 3, sorted.size() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 4, ((Cheese)sorted.get( 2 ).get( "stilton" )).getPrice() ); assertEquals( 2, sorted.size() ); assertEquals( 3, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 4, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() );
/** * Creates a {@link ThresholdList} that provides range-filtering on the * specified {@link EventList} using the specified {@link Evaluator}. */ public ThresholdList(EventList<E> source, Evaluator<E> evaluator) { this(new SortedList<E>(source, new ThresholdComparator<E>(evaluator)), evaluator); }
/** * Creates a {@link SortedList} that sorts the specified {@link EventList} * using the specified {@link Comparator} to determine sort order. If the * specified {@link Comparator} is <code>null</code>, then this {@link List} * will be unsorted. */ public SortedList(EventList<E> source, Comparator<? super E> comparator) { super(source); setComparator(comparator); source.addListEventListener(this); }
/** {@inheritDoc} */ @Override public boolean contains(Object object) { beforeReadOperation(); try { return delegate.contains(object); } finally { afterReadOperation(); } }
/** {@inheritDoc} */ @Override public E remove(int index) { beforeWriteOperation(); try { return delegate.remove(index); } finally { afterWriteOperation(); } }
/** {@inheritDoc} */ @Override public <T> T[] toArray(T[] array) { beforeReadOperation(); try { return delegate.toArray(array); } finally { afterReadOperation(); } }
/** {@inheritDoc} */ @Override public E set(int index, E value) { beforeWriteOperation(); try { return delegate.set(index, value); } finally { afterWriteOperation(); } }
/** {@inheritDoc} */ @Override public void dispose() { source.removeListEventListener(this); initializationData.dispose(); }
/** {@inheritDoc} */ @Override public E get(int visibleIndex) { return getTreeNode(visibleIndex).getElement(); }
/** * Private constructor is used as a Java-language hack to allow us to save * a reference to the specified {@link UniqueList}. */ private PopularityList(UniqueList<E> uniqueList) { super(new SortedList<E>(uniqueList, new PopularityComparator<E>(uniqueList))); this.uniqueList = uniqueList; // listen for changes to the source list source.addListEventListener(this); }