mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 13:21:07 +01:00
add push() and pop() to String/Int/FloatList
This commit is contained in:
@@ -137,6 +137,22 @@ public class FloatList implements Iterable<Float> {
|
||||
}
|
||||
|
||||
|
||||
/** 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.
|
||||
*
|
||||
|
||||
@@ -157,6 +157,22 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
|
||||
/** 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
|
||||
*
|
||||
|
||||
@@ -140,6 +140,22 @@ public class StringList implements Iterable<String> {
|
||||
}
|
||||
|
||||
|
||||
/** 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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user