From b3e3ebea72a41bef5a3e69676d5507eebdb2bc3c Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Tue, 11 Nov 2014 09:26:13 -0500 Subject: [PATCH] add insert(index, item) for single elements --- core/src/processing/data/FloatList.java | 8 +++++++- core/src/processing/data/IntList.java | 8 +++++++- core/src/processing/data/StringList.java | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 0238fe729..700d25b3b 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -299,6 +299,11 @@ public class FloatList implements Iterable { // } + public void insert(int index, float value) { + insert(index, new float[] { value }); + } + + // same as splice public void insert(int index, float[] values) { if (index < 0) { @@ -728,7 +733,8 @@ public class FloatList implements Iterable { /** - * Copy as many values as possible into the specified array. + * Copy values into the specified array. If the specified array is null or + * not the same size, a new array will be allocated. * @param array */ public float[] array(float[] array) { diff --git a/core/src/processing/data/IntList.java b/core/src/processing/data/IntList.java index 00483f927..091129b88 100644 --- a/core/src/processing/data/IntList.java +++ b/core/src/processing/data/IntList.java @@ -268,6 +268,11 @@ public class IntList implements Iterable { // } + public void insert(int index, int value) { + insert(index, new int[] { value }); + } + + // same as splice public void insert(int index, int[] values) { if (index < 0) { @@ -673,7 +678,8 @@ public class IntList implements Iterable { /** - * Copy as many values as possible into the specified array. + * Copy values into the specified array. If the specified array is null or + * not the same size, a new array will be allocated. * @param array */ public int[] array(int[] array) { diff --git a/core/src/processing/data/StringList.java b/core/src/processing/data/StringList.java index c7e13769e..595affdcb 100644 --- a/core/src/processing/data/StringList.java +++ b/core/src/processing/data/StringList.java @@ -307,6 +307,11 @@ public class StringList implements Iterable { // } + public void insert(int index, String value) { + insert(index, new String[] { value }); + } + + // same as splice public void insert(int index, String[] values) { if (index < 0) { @@ -633,7 +638,8 @@ public class StringList implements Iterable { /** - * Copy as many values as possible into the specified array. + * Copy values into the specified array. If the specified array is null or + * not the same size, a new array will be allocated. * @param array */ public String[] array(String[] array) {