Introductie type ArrayCycle en consequent maken van add en remove methodes: nu zonder type in de naam.

This commit is contained in:
2011-02-08 14:38:20 +00:00
parent f653fc7f3d
commit 091dcdf855
2 changed files with 43 additions and 17 deletions

View File

@@ -0,0 +1,31 @@
package pm.util;
import java.util.ArrayList;
public class ArrayCycle<T> extends ArrayList<T> {
protected static final long serialVersionUID = 1L;
protected int index = 0;
public T current() {
return this.get(index);
}
public T previous() {
if (--index < 0) {
index = Math.max(0, size() - 1);
}
return get(index);
}
public T next() {
if (++index >= size()) {
index = 0;
}
return get(index);
}
public T reset() {
return get(index = 0);
}
}