/** Puts the specified object in the pool, making it eligible to be returned by {@link #obtain()}. If the pool already contains * {@link #max} free objects, the specified object is reset but not added to the pool. * <p> * The pool does not check if an object is already freed, so the same object must not be freed multiple times. */ public void free (T object) { if (object == null) throw new IllegalArgumentException("object cannot be null."); if (freeObjects.size < max) { freeObjects.add(object); peak = Math.max(peak, freeObjects.size); } reset(object); }
/** Puts the specified object in the pool, making it eligible to be returned by {@link #obtain()}. If the pool already contains * {@link #max} free objects, the specified object is reset but not added to the pool. * <p> * The pool does not check if an object is already freed, so the same object must not be freed multiple times. */ public void free (T object) { if (object == null) throw new IllegalArgumentException("object cannot be null."); if (freeObjects.size < max) { freeObjects.add(object); peak = Math.max(peak, freeObjects.size); } reset(object); }
/** Puts the specified objects in the pool. Null objects within the array are silently ignored. * <p> * The pool does not check if an object is already freed, so the same object must not be freed multiple times. * @see #free(Object) */ public void freeAll (Array<T> objects) { if (objects == null) throw new IllegalArgumentException("objects cannot be null."); Array<T> freeObjects = this.freeObjects; int max = this.max; for (int i = 0; i < objects.size; i++) { T object = objects.get(i); if (object == null) continue; if (freeObjects.size < max) freeObjects.add(object); reset(object); } peak = Math.max(peak, freeObjects.size); }
/** Puts the specified objects in the pool. Null objects within the array are silently ignored. * <p> * The pool does not check if an object is already freed, so the same object must not be freed multiple times. * @see #free(Object) */ public void freeAll (Array<T> objects) { if (objects == null) throw new IllegalArgumentException("objects cannot be null."); Array<T> freeObjects = this.freeObjects; int max = this.max; for (int i = 0; i < objects.size; i++) { T object = objects.get(i); if (object == null) continue; if (freeObjects.size < max) freeObjects.add(object); reset(object); } peak = Math.max(peak, freeObjects.size); }
@Override synchronized protected void reset(T object) { super.reset(object); }
/** Puts the specified object in the pool, making it eligible to be returned by {@link #obtain()}. If the pool already contains * {@link #max} free objects, the specified object is reset but not added to the pool. * <p> * The pool does not check if an object is already freed, so the same object must not be freed multiple times. */ public void free (T object) { if (object == null) throw new IllegalArgumentException("object cannot be null."); if (freeObjects.size < max) { freeObjects.add(object); peak = Math.max(peak, freeObjects.size); } reset(object); }
/** Puts the specified objects in the pool. Null objects within the array are silently ignored. * <p> * The pool does not check if an object is already freed, so the same object must not be freed multiple times. * @see #free(Object) */ public void freeAll (Array<T> objects) { if (objects == null) throw new IllegalArgumentException("objects cannot be null."); Array<T> freeObjects = this.freeObjects; int max = this.max; for (int i = 0; i < objects.size; i++) { T object = objects.get(i); if (object == null) continue; if (freeObjects.size < max) freeObjects.add(object); reset(object); } peak = Math.max(peak, freeObjects.size); }