update
This commit is contained in:
44
java/wspp/IntList.java
Normal file
44
java/wspp/IntList.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package wspp;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Nikita Doschennikov (me@fymio.us)
|
||||
*/
|
||||
public class IntList {
|
||||
|
||||
protected int[] list = new int[8];
|
||||
protected int idx = 0;
|
||||
|
||||
public IntList() {}
|
||||
|
||||
public void put(int val) {
|
||||
if (idx >= list.length) {
|
||||
list = Arrays.copyOf(list, list.length * 2);
|
||||
}
|
||||
|
||||
list[idx++] = val;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return idx;
|
||||
}
|
||||
|
||||
public int get(int index) {
|
||||
return list[index];
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < idx; i++) {
|
||||
if (i == idx - 1) {
|
||||
sb.append(String.valueOf(list[i]) + "\n");
|
||||
} else {
|
||||
sb.append(String.valueOf(list[i]) + " ");
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user