/** * Removes all of the elements from this list. This * list will be empty after this call returns (unless * it throws an exception). */ public void clear() { /* // this is the quick way, but would force us // to break all the cursors _modCount++; _head.setNext(null); _head.setPrev(null); _size = 0; */ Iterator<E> it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
@Override public Iterator<E> iterator() { checkForComod(); return super.iterator(); }
/** * Retains only the elements in this list that are contained in the * specified collection. In other words, removes * from this list all the elements that are not contained in the specified * collection. * * @param c collection that defines which elements this set will retain. * * @return <tt>true</tt> if this list changed as a result of the call. */ public boolean retainAll(Collection<?> c) { boolean changed = false; Iterator<?> it = iterator(); while(it.hasNext()) { if(!c.contains(it.next())) { it.remove(); changed = true; } } return changed; }
/** * Removes from this list all the elements that are contained in the * specified collection. * * @param c collection that defines which elements will be removed from * this list. * @return <tt>true</tt> if this list changed as a result of the call. */ public boolean removeAll(Collection<?> c) { if(0 == c.size() || 0 == _size) { return false; } else { boolean changed = false; Iterator<?> it = iterator(); while(it.hasNext()) { if(c.contains(it.next())) { it.remove(); changed = true; } } return changed; } }
/** * Returns pool info including {@link #getNumActive()}, {@link #getNumIdle()} * and a list of objects idle in the pool with their idle times. * * @return string containing debug information */ synchronized String debugInfo() { StringBuffer buf = new StringBuffer(); buf.append("Active: ").append(getNumActive()).append("\n"); buf.append("Idle: ").append(getNumIdle()).append("\n"); buf.append("Idle Objects:\n"); Iterator<ObjectTimestampPair<T>> it = _pool.iterator(); long time = System.currentTimeMillis(); while(it.hasNext()) { ObjectTimestampPair<T> pair = it.next(); buf.append("\t").append(pair.value).append("\t").append(time - pair.tstamp).append("\n"); } return buf.toString(); }
/** * Removes all of the elements from this list. This * list will be empty after this call returns (unless * it throws an exception). */ public void clear() { /* // this is the quick way, but would force us // to break all the cursors _modCount++; _head.setNext(null); _head.setPrev(null); _size = 0; */ Iterator it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
@Override public Iterator<E> iterator() { checkForComod(); return super.iterator(); }
@Override public Iterator<E> iterator() { checkForComod(); return super.iterator(); }
/** * Removes all of the elements from this list. This * list will be empty after this call returns (unless * it throws an exception). */ public void clear() { /* // this is the quick way, but would force us // to break all the cursors _modCount++; _head.setNext(null); _head.setPrev(null); _size = 0; */ Iterator<E> it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
/** * Removes all of the elements from this list. This * list will be empty after this call returns (unless * it throws an exception). */ public void clear() { /* // this is the quick way, but would force us // to break all the cursors _modCount++; _head.setNext(null); _head.setPrev(null); _size = 0; */ Iterator it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
/** * Removes all of the elements from this list. This * list will be empty after this call returns (unless * it throws an exception). */ public void clear() { /* // this is the quick way, but would force us // to break all the cursors _modCount++; _head.setNext(null); _head.setPrev(null); _size = 0; */ Iterator<E> it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
public Iterator iterator() { checkForComod(); return super.iterator(); }
/** * Retains only the elements in this list that are contained in the * specified collection. In other words, removes * from this list all the elements that are not contained in the specified * collection. * * @param c collection that defines which elements this set will retain. * * @return <tt>true</tt> if this list changed as a result of the call. */ public boolean retainAll(Collection c) { boolean changed = false; Iterator it = iterator(); while(it.hasNext()) { if(!c.contains(it.next())) { it.remove(); changed = true; } } return changed; }
/** * Retains only the elements in this list that are contained in the * specified collection. In other words, removes * from this list all the elements that are not contained in the specified * collection. * * @param c collection that defines which elements this set will retain. * * @return <tt>true</tt> if this list changed as a result of the call. */ public boolean retainAll(Collection<?> c) { boolean changed = false; Iterator<?> it = iterator(); while(it.hasNext()) { if(!c.contains(it.next())) { it.remove(); changed = true; } } return changed; }
public Iterator iterator() { checkForComod(); return super.iterator(); }
/** * Returns pool info including {@link #getNumActive()}, {@link #getNumIdle()} * and a list of objects idle in the pool with their idle times. * * @return string containing debug information */ synchronized String debugInfo() { StringBuffer buf = new StringBuffer(); buf.append("Active: ").append(getNumActive()).append("\n"); buf.append("Idle: ").append(getNumIdle()).append("\n"); buf.append("Idle Objects:\n"); Iterator<ObjectTimestampPair<T>> it = _pool.iterator(); long time = System.currentTimeMillis(); while(it.hasNext()) { ObjectTimestampPair<T> pair = it.next(); buf.append("\t").append(pair.value).append("\t").append(time - pair.tstamp).append("\n"); } return buf.toString(); }
/** * Returns pool info including {@link #getNumActive()}, {@link #getNumIdle()} * and a list of objects idle in the pool with their idle times. * * @return string containing debug information */ synchronized String debugInfo() { StringBuffer buf = new StringBuffer(); buf.append("Active: ").append(getNumActive()).append("\n"); buf.append("Idle: ").append(getNumIdle()).append("\n"); buf.append("Idle Objects:\n"); Iterator it = _pool.iterator(); long time = System.currentTimeMillis(); while(it.hasNext()) { ObjectTimestampPair pair = (ObjectTimestampPair)(it.next()); buf.append("\t").append(pair.value).append("\t").append(time - pair.tstamp).append("\n"); } return buf.toString(); }
/** * Returns pool info including {@link #getNumActive()}, {@link #getNumIdle()} * and a list of objects idle in the pool with their idle times. * * @return string containing debug information */ synchronized String debugInfo() { StringBuffer buf = new StringBuffer(); buf.append("Active: ").append(getNumActive()).append("\n"); buf.append("Idle: ").append(getNumIdle()).append("\n"); buf.append("Idle Objects:\n"); Iterator it = _pool.iterator(); long time = System.currentTimeMillis(); while(it.hasNext()) { ObjectTimestampPair pair = (ObjectTimestampPair)(it.next()); buf.append("\t").append(pair.value).append("\t").append(time - pair.tstamp).append("\n"); } return buf.toString(); }
/** * Returns pool info including {@link #getNumActive()}, {@link #getNumIdle()} * and a list of objects idle in the pool with their idle times. * * @return string containing debug information */ synchronized String debugInfo() { StringBuffer buf = new StringBuffer(); buf.append("Active: ").append(getNumActive()).append("\n"); buf.append("Idle: ").append(getNumIdle()).append("\n"); buf.append("Idle Objects:\n"); Iterator<ObjectTimestampPair<T>> it = _pool.iterator(); long time = System.currentTimeMillis(); while(it.hasNext()) { ObjectTimestampPair<T> pair = it.next(); buf.append("\t").append(pair.value).append("\t").append(time - pair.tstamp).append("\n"); } return buf.toString(); }
/** * Clears the specified pool, removing all pooled instances corresponding to the given <code>key</code>. * * @param key the key to clear */ public synchronized void clear(Object key) { final ObjectQueue pool = (ObjectQueue)(_poolMap.remove(key)); if(null == pool) { return; } else { _poolList.remove(key); for(Iterator it = pool.queue.iterator(); it.hasNext(); ) { try { _factory.destroyObject(key,((ObjectTimestampPair)(it.next())).value); } catch(Exception e) { // ignore error, keep destroying the rest } it.remove(); _totalIdle--; } } notifyAll(); }