當前位置: 首頁>>代碼示例>>Java>>正文


Java Pool.free方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.utils.Pool.free方法的典型用法代碼示例。如果您正苦於以下問題:Java Pool.free方法的具體用法?Java Pool.free怎麽用?Java Pool.free使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.utils.Pool的用法示例。


在下文中一共展示了Pool.free方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: freeAll

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
/** Frees the specified objects from the {@link #get(Class) pool}. Null objects within the array are silently ignored.
 * @param samePool If true, objects don't need to be from the same pool but the pool must be looked up for each object. */
static public void freeAll(Array objects, boolean samePool) {
    if (objects == null)
        throw new IllegalArgumentException("Objects cannot be null.");
    Pool pool = null;
    for (int i = 0, n = objects.size; i < n; i++) {
        Object object = objects.get(i);
        if (object == null)
            continue;
        if (pool == null) {
            pool = typePools.get(object.getClass().getName());
            if (pool == null)
                continue; // Ignore freeing an object that was never retained.
        }
        pool.free(object);
        if (!samePool)
            pool = null;
    }
}
 
開發者ID:langurmonkey,項目名稱:gaiasky,代碼行數:21,代碼來源:MyPools.java

示例2: registerType

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static <T> void registerType(Class<? extends T> c, Pool<T> aPool) {
	T obj = aPool.obtain();
	Class<?> objClass = obj.getClass();
	aPool.free(obj);
	if (objClass.equals(c)) {
		synchronized (Pools.pools) {
			if (!Pools.pools.containsKey(c)) {
				Pools.pools.put(c, aPool);
			}
		}
	} else {
		throw new CubesException("Calling obtain on " + aPool + " does not return " + c.getName());
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:15,代碼來源:Pools.java

示例3: free

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static <T> void free(Class<T> c, T obj) {
	Pool<T> pool = pool(c);
	if (pool == null)
		return;
	synchronized (pool) {
		pool.free(obj);
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:9,代碼來源:Pools.java

示例4: registerType

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static <T> void registerType(Class<? extends T> c, Pool<T> pool) {
  T obj = pool.obtain();
  Class<?> objClass = obj.getClass();
  pool.free(obj);
  if (objClass.equals(c)) {
    synchronized (pools) {
      if (!pools.containsKey(c)) {
        pools.put(c, pool);
      }
    }
  } else {
    throw new CubesException("Calling obtain on " + pool + " does not return " + c.getName());
  }
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:15,代碼來源:Pools.java

示例5: free

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static <T> void free(Class<T> c, T obj) {
  Pool<T> pool = pool(c);
  if (pool == null) return;
  synchronized (pool) {
    pool.free(obj);
  }
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:8,代碼來源:Pools.java

示例6: reset

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
@Override
public void reset()
{
    Pool<Vertex> vertexPool = Pools.get(Vertex.class);
    for (Vertex vertex : this.vertices)
    {
        vertexPool.free(vertex);
    }
    this.vertices = null;
}
 
開發者ID:overengineering,項目名稱:space-travels-3,代碼行數:11,代碼來源:Projection.java

示例7: free

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
/** Frees an object from the {@link #get(Class) pool}. */
static public void free(Object object) {
    synchronized (lock) {
        if (object == null)
            throw new IllegalArgumentException("Object cannot be null.");
        Pool pool = typePools.get(object.getClass().getName());
        if (pool == null)
            return; // Ignore freeing an object that was never retained.
        pool.free(object);
    }
}
 
開發者ID:langurmonkey,項目名稱:gaiasky,代碼行數:12,代碼來源:MyPools.java

示例8: free

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
/** @param pool returns node to this pool. */
public void free(final Pool<Node<T>> pool) {
    reset();
    pool.free(this);
}
 
開發者ID:gdx-libs,項目名稱:gdx-kiwi,代碼行數:6,代碼來源:PooledList.java

示例9: calculateOffsets

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
@Override
protected void calculateOffsets () {
	super.calculateOffsets();
	if (chunkUpdateScheduled == false) return;
	chunkUpdateScheduled = false;
	highlights.sort();
	renderChunks.clear();

	String text = getText();

	Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class);
	GlyphLayout layout = layoutPool.obtain();
	boolean carryHighlight = false;
	for (int lineIdx = 0, highlightIdx = 0; lineIdx < linesBreak.size; lineIdx += 2) {
		int lineStart = linesBreak.items[lineIdx];
		int lineEnd = linesBreak.items[lineIdx + 1];
		int lineProgress = lineStart;
		float chunkOffset = 0;

		for (; highlightIdx < highlights.size; ) {
			Highlight highlight = highlights.get(highlightIdx);
			if (highlight.getStart() > lineEnd) {
				break;
			}

			if (highlight.getStart() == lineProgress || carryHighlight) {
				renderChunks.add(new Chunk(text.substring(lineProgress, Math.min(highlight.getEnd(), lineEnd)), highlight.getColor(), chunkOffset, lineIdx));
				lineProgress = Math.min(highlight.getEnd(), lineEnd);

				if (highlight.getEnd() > lineEnd) {
					carryHighlight = true;
				} else {
					carryHighlight = false;
					highlightIdx++;
				}
			} else {
				//protect against overlapping highlights
				boolean noMatch = false;
				while (highlight.getStart() <= lineProgress) {
					highlightIdx++;
					if (highlightIdx >= highlights.size) {
						noMatch = true;
						break;
					}
					highlight = highlights.get(highlightIdx);
					if (highlight.getStart() > lineEnd) {
						noMatch = true;
						break;
					}
				}
				if (noMatch) break;
				renderChunks.add(new Chunk(text.substring(lineProgress, highlight.getStart()), defaultColor, chunkOffset, lineIdx));
				lineProgress = highlight.getStart();
			}

			Chunk chunk = renderChunks.peek();
			layout.setText(style.font, chunk.text);
			chunkOffset += layout.width;
			//current highlight needs to be applied to next line meaning that there is no other highlights that can be applied to currently parsed line
			if (carryHighlight) break;
		}

		if (lineProgress < lineEnd) {
			renderChunks.add(new Chunk(text.substring(lineProgress, lineEnd), defaultColor, chunkOffset, lineIdx));
		}
	}

	maxAreaWidth = 0;
	for (String line : text.split("\\n")) {
		layout.setText(style.font, line);
		maxAreaWidth = Math.max(maxAreaWidth, layout.width + 30);
	}

	layoutPool.free(layout);
	updateScrollLayout();
}
 
開發者ID:kotcrab,項目名稱:vis-editor,代碼行數:77,代碼來源:HighlightTextArea.java

示例10: calculateOffsets

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
@Override
protected void calculateOffsets () {
	super.calculateOffsets();
	if (!this.text.equals(lastText)) {
		this.lastText = text;
		BitmapFont font = style.font;
		float maxWidthLine = this.getWidth()
				- (style.background != null ? style.background.getLeftWidth() + style.background.getRightWidth() : 0);
		linesBreak.clear();
		int lineStart = 0;
		int lastSpace = 0;
		char lastCharacter;
		Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class);
		GlyphLayout layout = layoutPool.obtain();
		for (int i = 0; i < text.length(); i++) {
			lastCharacter = text.charAt(i);
			if (lastCharacter == ENTER_DESKTOP || lastCharacter == ENTER_ANDROID) {
				linesBreak.add(lineStart);
				linesBreak.add(i);
				lineStart = i + 1;
			} else {
				lastSpace = (continueCursor(i, 0) ? lastSpace : i);
				layout.setText(font, text.subSequence(lineStart, i + 1));
				if (layout.width > maxWidthLine && softwrap) {
					if (lineStart >= lastSpace) {
						lastSpace = i - 1;
					}
					linesBreak.add(lineStart);
					linesBreak.add(lastSpace + 1);
					lineStart = lastSpace + 1;
					lastSpace = lineStart;
				}
			}
		}
		layoutPool.free(layout);
		// Add last line
		if (lineStart < text.length()) {
			linesBreak.add(lineStart);
			linesBreak.add(text.length());
		}
		showCursor();
	}
}
 
開發者ID:kotcrab,項目名稱:vis-editor,代碼行數:44,代碼來源:VisTextArea.java

示例11: disposeBehaviorTree

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
@Override
public void disposeBehaviorTree(final String treeReference, BehaviorTree<?> behaviorTree) {
	Pool<BehaviorTree> pool = getPool(treeReference);
	pool.free(behaviorTree);
}
 
開發者ID:libgdx,項目名稱:gdx-ai,代碼行數:6,代碼來源:PooledBehaviorTreeLibrary.java


注:本文中的com.badlogic.gdx.utils.Pool.free方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。