public Node<E> obtain (Node<E> p, Node<E> n, E value, int index) { Node<E> newNode = super.obtain(); newNode.p = p; newNode.n = n; newNode.value = value; newNode.index = index; return newNode; } }
/** Removes the tail of the list regardless of iteration status */ public T removeLast () { if (tail == null) { return null; } T payload = tail.payload; size--; Item<T> p = tail.prev; pool.free(tail); if (size == 0) { head = null; tail = null; } else { tail = p; tail.next = null; } return payload; }
private void clearDebugRects () { if (debugRects == null) return; DebugRect.pool.freeAll(debugRects); debugRects.clear(); }
public void renderSkeleton (final Vector3 from, final Node node) { final Vector3 pos = vectorPool.obtain(); node.globalTransform.getTranslation(pos); shapeRenderer.setColor(node.isAnimated ? Color.RED : Color.YELLOW); shapeRenderer.box(pos.x, pos.y, pos.z, 0.5f, 0.5f, 0.5f); shapeRenderer.setColor(Color.WHITE); shapeRenderer.line(from.x, from.y, from.z, pos.x, pos.y, pos.z); for (Node child : node.getChildren()) renderSkeleton(pos, child); vectorPool.free(pos); }
private void getTiles (int startX, int startY, int endX, int endY, Array<Rectangle> tiles) { TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get("walls"); rectPool.freeAll(tiles); tiles.clear(); for (int y = startY; y <= endY; y++) { for (int x = startX; x <= endX; x++) { Cell cell = layer.getCell(x, y); if (cell != null) { Rectangle rect = rectPool.obtain(); rect.set(x, y, 1, 1); tiles.add(rect); } } } }
/** Removes all actors and cells from the table. */ public void clearChildren () { Array<Cell> cells = this.cells; for (int i = cells.size - 1; i >= 0; i--) { Cell cell = cells.get(i); Actor actor = cell.actor; if (actor != null) actor.remove(); } cellPool.freeAll(cells); cells.clear(); rows = 0; columns = 0; if (rowDefaults != null) cellPool.free(rowDefaults); rowDefaults = null; implicitEndRow = false; super.clearChildren(); }
@Override public void clear () { // Dispose every allocated instance because the templates may be changed for (int i = 0, free = pool.getFree(); i < free; ++i) { pool.obtain().dispose(); } super.clear(); } }
public void layout () { BitmapFont font = style.font; Drawable selectedDrawable = style.selection; itemHeight = font.getCapHeight() - font.getDescent() * 2; itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight(); prefWidth = 0; Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class); GlyphLayout layout = layoutPool.obtain(); for (int i = 0; i < items.size; i++) { layout.setText(font, toString(items.get(i))); prefWidth = Math.max(layout.width, prefWidth); } layoutPool.free(layout); prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth(); prefHeight = items.size * itemHeight; Drawable background = style.background; if (background != null) { prefWidth += background.getLeftWidth() + background.getRightWidth(); prefHeight += background.getTopHeight() + background.getBottomHeight(); } }
@Override public void beforeGroup (int group, Array<Decal> contents) { if (group == GROUP_BLEND) { Gdx.gl.glEnable(GL20.GL_BLEND); contents.sort(cameraSorter); } else { for (int i = 0, n = contents.size; i < n; i++) { Decal decal = contents.get(i); Array<Decal> materialGroup = materialGroups.get(decal.material); if (materialGroup == null) { materialGroup = arrayPool.obtain(); materialGroup.clear(); usedArrays.add(materialGroup); materialGroups.put(decal.material, materialGroup); } materialGroup.add(decal); } contents.clear(); for (Array<Decal> materialGroup : materialGroups.values()) { contents.addAll(materialGroup); } materialGroups.clear(); arrayPool.freeAll(usedArrays); usedArrays.clear(); } }
/** Removes all actors and cells from the table. */ public void clearChildren () { Array<Cell> cells = this.cells; for (int i = cells.size - 1; i >= 0; i--) { Cell cell = cells.get(i); Actor actor = cell.actor; if (actor != null) actor.remove(); } cellPool.freeAll(cells); cells.clear(); rows = 0; columns = 0; if (rowDefaults != null) cellPool.free(rowDefaults); rowDefaults = null; implicitEndRow = false; super.clearChildren(); }
@Override public void clear () { // Dispose every allocated instance because the templates may be changed for (int i = 0, free = pool.getFree(); i < free; ++i) { pool.obtain().dispose(); } super.clear(); } }
public Node<E> obtain (Node<E> p, Node<E> n, E value, int index) { Node<E> newNode = super.obtain(); newNode.p = p; newNode.n = n; newNode.value = value; newNode.index = index; return newNode; } }
/** Removes the tail of the list regardless of iteration status */ public T removeLast () { if (tail == null) { return null; } T payload = tail.payload; size--; Item<T> p = tail.prev; pool.free(tail); if (size == 0) { head = null; tail = null; } else { tail = p; tail.next = null; } return payload; }
public void layout () { BitmapFont font = style.font; Drawable selectedDrawable = style.selection; itemHeight = font.getCapHeight() - font.getDescent() * 2; itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight(); prefWidth = 0; Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class); GlyphLayout layout = layoutPool.obtain(); for (int i = 0; i < items.size; i++) { layout.setText(font, toString(items.get(i))); prefWidth = Math.max(layout.width, prefWidth); } layoutPool.free(layout); prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth(); prefHeight = items.size * itemHeight; Drawable background = style.background; if (background != null) { prefWidth += background.getLeftWidth() + background.getRightWidth(); prefHeight += background.getTopHeight() + background.getBottomHeight(); } }
@Override public void beforeGroup (int group, Array<Decal> contents) { if (group == GROUP_BLEND) { Gdx.gl.glEnable(GL20.GL_BLEND); contents.sort(cameraSorter); } else { for (int i = 0, n = contents.size; i < n; i++) { Decal decal = contents.get(i); Array<Decal> materialGroup = materialGroups.get(decal.material); if (materialGroup == null) { materialGroup = arrayPool.obtain(); materialGroup.clear(); usedArrays.add(materialGroup); materialGroups.put(decal.material, materialGroup); } materialGroup.add(decal); } contents.clear(); for (Array<Decal> materialGroup : materialGroups.values()) { contents.addAll(materialGroup); } materialGroups.clear(); arrayPool.freeAll(usedArrays); usedArrays.clear(); } }
public void flush () { super.freeAll(obtained); obtained.clear(); } }
private AnimationDesc obtain (final Animation anim, float offset, float duration, int loopCount, float speed, final AnimationListener listener) { if (anim == null) return null; final AnimationDesc result = animationPool.obtain(); result.animation = anim; result.listener = listener; result.loopCount = loopCount; result.speed = speed; result.offset = offset; result.duration = duration < 0 ? (anim.duration - offset) : duration; result.time = speed < 0 ? result.duration : 0.f; return result; }
@Override public void free (T object) { obtained.removeValue(object, true); super.free(object); }
colors.add(colorPool.obtain().set(hits.get(i).getColor())); hits.get(i).setColor(Color.RED); colors.add(colorPool.obtain().set(contacts.get(i).getColor())); contacts.get(i).setColor(Color.BLUE); for (int i = 0; i < contacts.size; i++) contacts.get(i).setColor(colors.get(hits.size + i)); colorPool.freeAll(colors); colors.clear();
@Override public void freeAll (Array<T> objects) { obtained.removeAll(objects, true); super.freeAll(objects); } }