Documentation of 'processing.data.StringList' Java class
StringList
processing.data

Class StringList

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.String>


    public class StringList
    extends java.lang.Object
    implements java.lang.Iterable<java.lang.String>
    Helper class for a list of Strings. Lists are designed to have some of the features of ArrayLists, but to maintain the simplicity and efficiency of working with arrays. Functions like sort() and shuffle() always act on the list itself. To get a sorted copy, use list.copy().sort().
    See Also:
    IntList, FloatList
    • Constructor Summary

      Constructors 
      Constructor and Description
      StringList() 
      StringList(int length) 
      StringList(java.lang.Iterable<java.lang.String> iter)
      Create from something iterable, for instance: StringList list = new StringList(hashMap.keySet());
      StringList(java.lang.Object... items)
      Construct a StringList from a random pile of objects.
      StringList(java.lang.String[] list) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void append(java.lang.String value)
      Add a new entry to the list.
      void append(java.lang.String[] values) 
      void append(StringList list) 
      void appendUnique(java.lang.String value)
      Add this value, but only if it's not already in the list.
      java.lang.String[] array()
      Create a new array with a copy of all the values.
      java.lang.String[] array(java.lang.String[] array)
      Copy values into the specified array.
      void clear()
      Remove all entries from the list.
      StringList copy() 
      java.lang.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.
      java.lang.String[] getUnique()
      Get a list of all unique entries.
      boolean hasValue(java.lang.String value) 
      int index(java.lang.String what)
      Return the first index of a particular value.
      void insert(int index, java.lang.String value) 
      void insert(int index, java.lang.String[] values) 
      void insert(int index, StringList list) 
      java.util.Iterator<java.lang.String> iterator() 
      java.lang.String join(java.lang.String separator) 
      void lower()
      Make the entire list lower case.
      java.lang.String pop() 
      void print() 
      void push(java.lang.String value)
      Just an alias for append(), but matches pop()
      java.lang.String remove(int index)
      Remove an element from the specified index.
      int removeValue(java.lang.String value) 
      int removeValues(java.lang.String value) 
      int replaceValue(java.lang.String value, java.lang.String newValue) 
      int replaceValues(java.lang.String value, java.lang.String newValue) 
      void resize(int length) 
      void reverse() 
      void set(int index, java.lang.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.
      java.lang.String toString() 
      void upper()
      Make the entire list upper case.
      java.lang.String[] values()
      Returns the actual array being used to store the data.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • StringList

        public StringList()
      • StringList

        public StringList(int length)
      • StringList

        public StringList(java.lang.String[] list)
      • StringList

        public StringList(java.lang.Object... items)
        Construct a StringList from a random pile of objects. Null values will stay null, but all the others will be converted to String values.
      • StringList

        public StringList(java.lang.Iterable<java.lang.String> iter)
        Create from something iterable, for instance: StringList list = new StringList(hashMap.keySet());
    • Method Detail

      • size

        public int size()
        Get the length of the list.
      • resize

        public void resize(int length)
      • clear

        public void clear()
        Remove all entries from the list.
      • get

        public java.lang.String get(int index)
        Get an entry at a particular index.
      • set

        public void set(int index,
                        java.lang.String what)
        Set the entry at a particular index. If the index is past the length of the list, it'll expand the list to accommodate, and fill the intermediate entries with 0s.
      • push

        public void push(java.lang.String value)
        Just an alias for append(), but matches pop()
      • pop

        public java.lang.String pop()
      • remove

        public java.lang.String remove(int index)
        Remove an element from the specified index.
      • removeValue

        public int removeValue(java.lang.String value)
      • removeValues

        public int removeValues(java.lang.String value)
      • replaceValue

        public int replaceValue(java.lang.String value,
                                java.lang.String newValue)
      • replaceValues

        public int replaceValues(java.lang.String value,
                                 java.lang.String newValue)
      • append

        public void append(java.lang.String value)
        Add a new entry to the list.
      • append

        public void append(java.lang.String[] values)
      • appendUnique

        public void appendUnique(java.lang.String value)
        Add this value, but only if it's not already in the list.
      • insert

        public void insert(int index,
                           java.lang.String value)
      • insert

        public void insert(int index,
                           java.lang.String[] values)
      • insert

        public void insert(int index,
                           StringList list)
      • index

        public int index(java.lang.String what)
        Return the first index of a particular value.
      • hasValue

        public boolean hasValue(java.lang.String value)
      • sort

        public void sort()
        Sorts the array in place.
      • sortReverse

        public void sortReverse()
        Reverse sort, orders values from highest to lowest.
      • reverse

        public void reverse()
      • shuffle

        public void shuffle()
        Randomize the order of the list elements. Note that this does not obey the randomSeed() function in PApplet.
      • shuffle

        public void shuffle(PApplet sketch)
        Randomize the list order using the random() function from the specified sketch, allowing shuffle() to use its current randomSeed() setting.
      • lower

        public void lower()
        Make the entire list lower case.
      • upper

        public void upper()
        Make the entire list upper case.
      • values

        public java.lang.String[] values()
        Returns the actual array being used to store the data. Suitable for iterating with a for() loop, but modifying the list could cause terrible things to happen.
      • iterator

        public java.util.Iterator<java.lang.String> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.String>
      • array

        public java.lang.String[] array()
        Create a new array with a copy of all the values.
        Returns:
        an array sized by the length of the list with each of the values.
      • array

        public java.lang.String[] array(java.lang.String[] array)
        Copy values into the specified array. If the specified array is null or not the same size, a new array will be allocated.
        Parameters:
        array -
      • getSubset

        public StringList getSubset(int start)
      • getSubset

        public StringList getSubset(int start,
                                    int num)
      • getUnique

        public java.lang.String[] getUnique()
        Get a list of all unique entries.
      • getTally

        public IntDict getTally()
        Count the number of times each String entry is found in this list.
      • getOrder

        public IntDict getOrder()
        Create a dictionary associating each entry in this list to its index.
      • join

        public java.lang.String join(java.lang.String separator)
      • print

        public void print()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.