This commit is contained in:
@@ -12,6 +12,10 @@ public class IntList {
|
||||
|
||||
public IntList() {}
|
||||
|
||||
public IntList(int[] list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public void put(int val) {
|
||||
if (idx >= list.length) {
|
||||
list = Arrays.copyOf(list, list.length * 2);
|
||||
@@ -24,6 +28,16 @@ public class IntList {
|
||||
return idx;
|
||||
}
|
||||
|
||||
public IntList getReversed() {
|
||||
IntList reverse = new IntList(new int[idx]);
|
||||
|
||||
for (int i = idx - 1; i >= 0; i--) {
|
||||
reverse.put(list[i]);
|
||||
}
|
||||
|
||||
return reverse;
|
||||
}
|
||||
|
||||
public int get(int index) {
|
||||
return list[index];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user