public class StringList
extends Object
implements Iterable<String>
Constructor and Description |
---|
StringList() |
StringList(int length) |
StringList(Iterable<String> iter)
Create from something iterable, for instance:
StringList list = new StringList(hashMap.keySet());
|
StringList(Object... items)
Construct a StringList from a random pile of objects.
|
StringList(String[] list) |
Modifier and Type | Method and Description |
---|---|
void |
append(String value)
Add a new entry to the list.
|
void |
append(String[] values) |
void |
append(StringList list) |
void |
appendUnique(String value)
Add this value, but only if it's not already in the list.
|
String[] |
array()
Create a new array with a copy of all the values.
|
String[] |
array(String[] array)
Copy values into the specified array.
|
void |
clear()
Remove all entries from the list.
|
StringList |
copy() |
String |
get(int index)
Get an entry at a particular index.
|
IntDict |
getOrder()
Create a dictionary associating each entry in this list to its index.
|
StringList |
getSubset(int start) |
StringList |
getSubset(int start,
int num) |
IntDict |
getTally()
Count the number of times each String entry is found in this list.
|
String[] |
getUnique()
Get a list of all unique entries.
|
boolean |
hasValue(String value) |
int |
index(String what)
Return the first index of a particular value.
|
void |
insert(int index,
String value) |
void |
insert(int index,
String[] values) |
void |
insert(int index,
StringList list) |
Iterator<String> |
iterator() |
String |
join(String separator) |
void |
lower()
Make the entire list lower case.
|
String |
pop() |
void |
print() |
void |
push(String value)
Just an alias for append(), but matches pop()
|
String |
remove(int index)
Remove an element from the specified index.
|
int |
removeValue(String value) |
int |
removeValues(String value) |
int |
replaceValue(String value,
String newValue) |
int |
replaceValues(String value,
String newValue) |
void |
resize(int length) |
void |
reverse() |
void |
save(File file)
Save tab-delimited entries to a file (TSV format, UTF-8 encoding)
|
void |
set(int index,
String what)
Set the entry at a particular index.
|
void |
shuffle()
Randomize the order of the list elements.
|
void |
shuffle(PApplet sketch)
Randomize the list order using the random() function from the specified
sketch, allowing shuffle() to use its current randomSeed() setting.
|
int |
size()
Get the length of the list.
|
void |
sort()
Sorts the array in place.
|
void |
sortReverse()
Reverse sort, orders values from highest to lowest.
|
String |
toJSON()
Return this dictionary as a String in JSON format.
|
String |
toString() |
void |
upper()
Make the entire list upper case.
|
String[] |
values()
Returns the actual array being used to store the data.
|
void |
write(PrintWriter writer)
Write entries to a PrintWriter, one per line
|
public StringList()
public StringList(int length)
public StringList(String[] list)
public StringList(Object... items)
public StringList(Iterable<String> iter)
public int size()
public void resize(int length)
public void clear()
public String get(int index)
public void set(int index, String what)
public void push(String value)
public String pop()
public String remove(int index)
public int removeValue(String value)
public int removeValues(String value)
public int replaceValue(String value, String newValue)
public int replaceValues(String value, String newValue)
public void append(String value)
public void append(String[] values)
public void append(StringList list)
public void appendUnique(String value)
public void insert(int index, String value)
public void insert(int index, String[] values)
public void insert(int index, StringList list)
public int index(String what)
public boolean hasValue(String value)
public void sort()
public void sortReverse()
public void reverse()
public void shuffle()
public void shuffle(PApplet sketch)
public void lower()
public void upper()
public StringList copy()
public String[] values()
public Iterator<String> iterator()
iterator
in interface Iterable<String>
public String[] array()
public String[] array(String[] array)
array
- public StringList getSubset(int start)
public StringList getSubset(int start, int num)
public String[] getUnique()
public IntDict getTally()
public IntDict getOrder()
public String join(String separator)
public void print()
public void save(File file)
public void write(PrintWriter writer)
public String toJSON()
public String toString()
toString
in class Object