Back to project page DivisionByZero.
The source code is released under:
Apache License
If you think the Android project DivisionByZero listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ggstudios.divisionbyzero; //from ww w.j a v a 2 s. c o m import java.util.ArrayList; import java.util.Collections; public class UpdatableCollection implements Updatable{ private ArrayList<Updatable> items = new ArrayList<Updatable>(); private int len = 0; public void add(Updatable d) { if(items.size() == len) { items.add(d); } else { items.set(len, d); } len++; } public void remove(int index) { Collections.swap(items, index, len - 1); len--; } public void remove(Updatable item) { int index = items.indexOf(item); if(index == -1 || index >= len) return; Collections.swap(items, index, len - 1); len--; } public void clear() { len = 0; } public int find(Updatable item) { for(int i = len - 1; i >= 0; i--) if (items.get(i).equals(item)) return i; return -1; } @Override public boolean update(float dt) { for(int i = len - 1; i >= 0; i--) { if( !items.get(i).update(dt) ) { remove(i); } } return true; } public int size() { return len; } }