[英]What array class has a remove and return object method?
哪個libgdx可迭代的類具有remove和return方法? 將在下面的代碼中使用。
Array<Entity> entities = new Array<Entity>();
Array<Entity> entitiesToRemove = new Array<Entity>();
Entity entityToRemove = entities.remove(entity);
entitiesToRemove .add(entityToRemove);
據我所知,沒有具有刪除和返回對象方法的數組類。 我會這樣解決:
for (int i = 0; i < array.size; i++) {
array.get(i);
array.removeIndex(i);
}
通常,任何隊列數據結構都具有此檢索和刪除功能。 在您的情況下,本機Java隊列(或簡單的LinkedList)將已經具有該功能,但是由於您需要一個libgdx類:
您感興趣的功能有:
T removeFirst()
Remove the first item from the queue.
T removeIndex(int index)
Removes and returns the item at the specified index.
T removeLast()
Remove the last item from the queue.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.