/** * Constructor. * * @param elementType the allowed type of elements, or null for no * restrictions * @param ordered true if this collection is ordered */ public AbstractLRSProxyCollection(Class elementType, boolean ordered) { _elementType = elementType; _ct = new CollectionChangeTrackerImpl(this, false, ordered,false); _ct.setAutoOff(false); }
public void added(Object val) { _ct.added(val); }
protected void remove(Object elem) { // if the collection contains multiple copies of the elem, we can't // use change tracking because some back-ends can't just delete a // single copy of a elem if (_dups && getAutoOff() && _coll.contains(elem)) stopTracking(); else if (add == null || !add.remove(elem)) { // after a point it's inefficient to keep tracking if (getAutoOff() && getRemoved().size() + getAdded().size() >= _coll.size()) stopTracking(); else { if (rem == null) rem = newSet(); rem.add(elem); } } }
public boolean contains(Object o) { if (_elementType != null && !_elementType.isInstance(o)) return false; if (_ct.getAdded().contains(o)) return true; if (_ct.getRemoved().contains(o)) return false; if (!has(o)) return false; return true; }
public void removed(Object val) { _ct.removed(val); }
public Collection getAdded() { return _ct.getAdded(); }
public Collection getRemoved() { return _ct.getRemoved(); }
public int getNextSequence() { return _ct.getNextSequence(); }
public boolean isTracking() { return _ct.isTracking(); }
public Collection getChanged() { return _ct.getChanged(); }
public int size() { if (_count == -1) _count = count(); if (_count == Integer.MAX_VALUE) return _count; return _count + _ct.getAdded().size() - _ct.getRemoved().size(); }
public void removed(Object val) { _ct.removed(val); }
public Collection getAdded() { return _ct.getAdded(); }
public Collection getRemoved() { return _ct.getRemoved(); }
public int getNextSequence() { return _ct.getNextSequence(); }
public boolean isTracking() { return _ct.isTracking(); }
public Collection getChanged() { return _ct.getChanged(); }
protected void remove(Object elem) { // if the collection contains multiple copies of the elem, we can't // use change tracking because some back-ends can't just delete a // single copy of a elem if (_dups && getAutoOff() && _coll.contains(elem)) stopTracking(); else if (add == null || !add.remove(elem)) { // after a point it's inefficient to keep tracking if (getAutoOff() && getRemoved().size() + getAdded().size() >= _coll.size()) stopTracking(); else { if (rem == null) rem = newSet(); rem.add(elem); } } }
public int size() { if (_count == -1) _count = count(); if (_count == Integer.MAX_VALUE) return _count; return _count + _ct.getAdded().size() - _ct.getRemoved().size(); }
public void removed(Object val) { _ct.removed(val); }