com.badlogic.gdx.utils.Pool.reset()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中com.badlogic.gdx.utils.Pool.reset()方法的一些代码示例,展示了Pool.reset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pool.reset()方法的具体详情如下:
包路径:com.badlogic.gdx.utils.Pool
类名称:Pool
方法名:reset

Pool.reset介绍

[英]Called when an object is freed to clear the state of the object for possible later reuse. The default implementation calls Poolable#reset() if the object is Poolable.
[中]在对象被释放时调用,以清除对象的状态,以便以后可能的重用。如果对象是可池的,则默认实现调用Poolable#reset()。

代码示例

代码示例来源:origin: libgdx/libgdx

/** 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);
}

代码示例来源:origin: libgdx/libgdx

/** 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);
}

代码示例来源:origin: libgdx/libgdx

/** 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);
}

代码示例来源:origin: libgdx/libgdx

/** 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);
}

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

@Override
synchronized
protected void reset(T object) {
  super.reset(object);
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

/** 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);
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

/** 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);
}

相关文章