diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 625850a1e..bc39a3ae3 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -137,6 +137,22 @@ public class FloatList implements Iterable { } + /** Just an alias for append(), but matches pop() */ + public void push(float value) { + append(value); + } + + + public float pop() { + if (count == 0) { + throw new RuntimeException("Can't call pop() on an empty list"); + } + float value = get(count-1); + count--; + return value; + } + + /** * Remove an element from the specified index. * diff --git a/core/src/processing/data/IntList.java b/core/src/processing/data/IntList.java index c591d3ae8..e9a310361 100644 --- a/core/src/processing/data/IntList.java +++ b/core/src/processing/data/IntList.java @@ -157,6 +157,22 @@ public class IntList implements Iterable { } + /** Just an alias for append(), but matches pop() */ + public void push(int value) { + append(value); + } + + + public int pop() { + if (count == 0) { + throw new RuntimeException("Can't call pop() on an empty list"); + } + int value = get(count-1); + count--; + return value; + } + + /** * Remove an element from the specified index * diff --git a/core/src/processing/data/StringList.java b/core/src/processing/data/StringList.java index 595affdcb..65d73ceb9 100644 --- a/core/src/processing/data/StringList.java +++ b/core/src/processing/data/StringList.java @@ -140,6 +140,22 @@ public class StringList implements Iterable { } + /** Just an alias for append(), but matches pop() */ + public void push(String value) { + append(value); + } + + + public String pop() { + if (count == 0) { + throw new RuntimeException("Can't call pop() on an empty list"); + } + String value = get(count-1); + count--; + return value; + } + + /** * Remove an element from the specified index. *