/** {@inheritDoc} */ public EventList createEventList(int initalCapacity) { return new BasicEventList(initalCapacity); } }
@Benchmark @Warmup(iterations = 3) @Measurement(iterations = 10) @Fork(3) public void testRemove() { while (list.size() < 500) { list.add(list.size()); } while (list.size() < 1000) { list.add(0, list.size()); } while (list.size() > 500) { list.remove(0); } while (list.size() > 0) { list.remove(list.size() - 1); } } }
/** {@inheritDoc} */ @Override public void clear() { // don't do a clear on an empty set if(isEmpty()) return; // create the change event updates.beginEvent(); for(int i = 0, size = size(); i < size; i++) { updates.elementDeleted(0, get(i)); } // do the actual clear data.clear(); // fire the event updates.commitEvent(); }
/** * Creates the list with null. * * @param sourceList * the source list * * @return the composite list< object> */ protected CompositeList<E> createListWithNull(EventList<E> sourceList) { // Creates a composite CompositeList<E> compositeList = new CompositeList<E>(sourceList .getPublisher(), sourceList.getReadWriteLock()); // Null list BasicEventList<E> nullList = new BasicEventList<E>(sourceList .getPublisher(), sourceList.getReadWriteLock()); nullList.add(null); // Composition compositeList.addMemberList(nullList); compositeList.addMemberList(sourceList); return compositeList; }
out.writeObject(getPublisher()); out.writeObject(getReadWriteLock());
/** {@inheritDoc} */ @Override public boolean remove(Object element) { int index = data.indexOf(element); if(index == -1) return false; remove(index); return true; }
/** {@inheritDoc} */ @Override public boolean add(E element) { // create the change event updates.beginEvent(); updates.elementInserted(size(), element); // do the actual add boolean result = data.add(element); // fire the event updates.commitEvent(); return result; }
/** {@inheritDoc} */ @Override public boolean removeAll(Collection<?> collection) { boolean changed = false; updates.beginEvent(); for(Iterator i = collection.iterator(); i.hasNext(); ) { Object value = i.next(); int index = -1; while((index = indexOf(value)) != -1) { E removed = data.remove(index); updates.elementDeleted(index, removed); changed = true; } } updates.commitEvent(); return changed; }
/** {@inheritDoc} */ @Override public void clear() { // don't do a clear on an empty set if(isEmpty()) return; // create the change event updates.beginEvent(); for(int i = 0, size = size(); i < size; i++) { updates.elementDeleted(0, get(i)); } // do the actual clear data.clear(); // fire the event updates.commitEvent(); }
out.writeObject(getPublisher()); out.writeObject(getReadWriteLock());
/** {@inheritDoc} */ @Override public boolean remove(Object element) { int index = data.indexOf(element); if(index == -1) return false; remove(index); return true; }
/** {@inheritDoc} */ @Override public boolean add(E element) { // create the change event updates.beginEvent(); updates.elementInserted(size(), element); // do the actual add boolean result = data.add(element); // fire the event updates.commitEvent(); return result; }
/** {@inheritDoc} */ @Override public boolean removeAll(Collection<?> collection) { boolean changed = false; updates.beginEvent(); for(Iterator i = collection.iterator(); i.hasNext(); ) { Object value = i.next(); int index = -1; while((index = indexOf(value)) != -1) { E removed = data.remove(index); updates.elementDeleted(index, removed); changed = true; } } updates.commitEvent(); return changed; }
/** * Constructs a PluggableList which uses the given <code>publisher</code> * and <code>lock</code>. The PluggableList will default to use a * {@link BasicEventList} that also uses the same <code>publisher</code> * and <code>lock</code>. * * @param publisher the {@link ListEventPublisher} to use within the {@link PluggableList} * @param lock the {@link ReadWriteLock} to use within the {@link PluggableList} */ public PluggableList(ListEventPublisher publisher, ReadWriteLock lock) { this(new BasicEventList<E>(publisher, lock)); }
/** {@inheritDoc} */ @Override public void clear() { // don't do a clear on an empty set if(isEmpty()) return; // create the change event updates.beginEvent(); for(int i = 0, size = size(); i < size; i++) { updates.elementDeleted(0, get(i)); } // do the actual clear data.clear(); // fire the event updates.commitEvent(); }
out.writeObject(getPublisher()); out.writeObject(getReadWriteLock());