/** * Adds all elements in this Collection. */ public boolean addAll(Collection<? extends E> c) { Assert.notNull(c,"Can not merge with NULL set"); writeLock.lock(); try { for (E object : c) { this.add(object); } return true; } finally { writeLock.unlock(); } }
/** * Every time an Ordered element is added via this method this * Set will be re-sorted, otherwise the element is simply added * to the end. Added element must not be null. */ public boolean add(E o) { Assert.notNull(o,"Can not add NULL object"); writeLock.lock(); try { boolean present = false; if (o instanceof Ordered){ present = this.addOrderedElement((Ordered) o); } else { present = super.add(o); } return present; } finally { writeLock.unlock(); } }
private boolean addOrderedElement(Ordered adding) { boolean added = false; E[] tempUnorderedElements = (E[]) this.toArray(); if (super.contains(adding)) { return false;