    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class sdsu.util.List

    java.lang.Object
       |
       +----sdsu.util.List

public class List
extends Object
implements OrderedCollection, Stringizable

A List object is a vector that can convert itself to a string and "recreate" itself from that string. The original List object can contain any objects, but the recreated List object will only contain string representations of the original elements in the list. In a List object string representation (Losr) the list elements are separated by a separatorChar, which defaults to ',', but can be changed. If the string representation of a list element contains a special character it is quoted. Special characters include separatorChar, a comment character, and white space characters. See sdsu.util.TokenCharacters for default values. White space and comments can be added to a Losr for readability. Comments start with a comment character and continue upto and include the next '\n' character.

Author:
  Roger Whitney (whitney@cs.sdsu.edu)
See Also:
  Stringizer, SimpleTokenizer, TokenCharacters

##

internalVector

##

List()
  Create a new list
List(int)
  Create a list with initial given size
List(Object[])
  Create a list initial items from a list
List(Vector)
  Create a list initial items from a list

##

addElement(double)
  Adds the specified double as the last element of the list.
addElement(int)
  Adds the specified int as the last element of the list.
addElement(Object)
addElements(Object[])
  Adds the array to the end of the list.
addElements(Vector)
  Adds the vector to the end of the list.
capacity()
clone()
contains(Object)
doubleAt(int)
  Returns the double at the specified index.
elementAt(int)
elements()
elementsReversed()
  Returns an enumeration of the elements inrevese order.
ensureCapacity(int)
firstElement()
fromString(String)
  Converts a string to a list.
indexOf(Object)
indexOf(Object, int)
insertElementAt(Object, int)
intAt(int)
  Returns the int at the specified index.
isEmpty()
lastElement()
lastIndexOf(Object)
lastIndexOf(Object, int)
load(InputStream)
  Converts a string to a list.
main(String[])
removeAllElements()
removeElement(Object)
removeElementAt(int)
replaceElements(Object[])
reversed()
  Returns a list with elements in the reverse order from present list
save(OutputStream, String)
  Writes ascii representation of List to Outputstream
setElementAt(Object, int)
setSeparatorChar(char)
  Set character used to separate elements of list in String representation of List
setSize(int)
setTokenCharacters(TokenCharacters)
  Sets TokenCharacters used to convert List from/to strings/streams.
shuffled()
  Returns a list with elements from present list, but in random order.
size()
toArray()
  Converts the list to an array.
toString()
  Converts the list to a string
toString(String)
  Converts the list to a string with given header information.
toVector()
  Converts the list to a vector.
trimToSize()

##

internalVector

     protected Vector internalVector

##

List

     public List()

  Create a new list

List

     public List(int initialSize)

  Create a list with initial given size

List

     public List(Vector initialElements)

  Create a list initial items from a list

List

     public List(Object list[])

  Create a list initial items from a list

##

fromString

     public void fromString(String listString) throws ConversionException

  Converts a string to a list. Converts strings created by a list or vector Items in string are separated by separatorChar

load

     public void load(InputStream in) throws ConversionException

  Converts a string to a list. Converts strings created by a list or vector Items in string are separated by separatorChar

toString

     public String toString()

  Converts the list to a string

  Overrides:
    toString in class Object

toString

     public String toString(String header)

  Converts the list to a string with given header information.

toVector

     public Vector toVector()

  Converts the list to a vector.

toArray

     public Object[] toArray()

  Converts the list to an array.

save

     public void save(OutputStream out,
                      String header)

  Writes ascii representation of List to Outputstream

setSeparatorChar

     public void setSeparatorChar(char separatorChar)

  Set character used to separate elements of list in String representation of List

setTokenCharacters

     public void setTokenCharacters(TokenCharacters newParseTable)

  Sets TokenCharacters used to convert List from/to strings/streams. Current values for separatorChar override separator settings in TokenCharacters object.

elementsReversed

     public final synchronized Enumeration elementsReversed()

  Returns an enumeration of the elements inrevese order. That is starts at the back of the list and goes toward the front of the list.

intAt

     public final synchronized int intAt(int index)

  Returns the int at the specified index.

  Parameters:
    index - the index of the desired element
  Throws: ArrayIndexOutOfBoundsException
    If an invalid index was given.
  Throws: ClassCastException
    If element at index is not really a numeric type which can be converted to an int.

doubleAt

     public final synchronized double doubleAt(int index)

  Returns the double at the specified index.

  Parameters:
    index - the index of the desired element
  Throws: ArrayIndexOutOfBoundsException
    If an invalid index was given.
  Throws: ClassCastException
    If element at index is not really a numeric type which can be converted to a double.

addElement

     public final synchronized void addElement(int anInt)

  Adds the specified int as the last element of the list.

  Parameters:
    anInt - the element to be added

addElement

     public final synchronized void addElement(double aDouble)

  Adds the specified double as the last element of the list.

  Parameters:
    aFloat - the element to be added

addElements

     public void addElements(Object elementsToAdd[])

  Adds the array to the end of the list.

addElements

     public void addElements(Vector elementsToAdd)

  Adds the vector to the end of the list.

reversed

     public synchronized OrderedCollection reversed()

  Returns a list with elements in the reverse order from present list

shuffled

     public synchronized OrderedCollection shuffled()

  Returns a list with elements from present list, but in random order.

elements

     public Enumeration elements()

trimToSize

     public void trimToSize()

ensureCapacity

     public void ensureCapacity(int minCapacity)

setSize

     public void setSize(int size)

capacity

     public int capacity()

size

     public int size()

isEmpty

     public boolean isEmpty()

contains

     public boolean contains(Object obj)

indexOf

     public int indexOf(Object obj)

indexOf

     public int indexOf(Object obj,
                        int i)

lastIndexOf

     public int lastIndexOf(Object obj)

lastIndexOf

     public int lastIndexOf(Object obj,
                            int i)

elementAt

     public Object elementAt(int i)

firstElement

     public Object firstElement()

lastElement

     public Object lastElement()

setElementAt

     public void setElementAt(Object obj,
                              int i)

removeElementAt

     public void removeElementAt(int i)

insertElementAt

     public void insertElementAt(Object obj,
                                 int i)

addElement

     public void addElement(Object obj)

removeElement

     public boolean removeElement(Object obj)

removeAllElements

     public void removeAllElements()

replaceElements

     public void replaceElements(Object objs[])

clone

     public synchronized Object clone()

  Overrides:
    clone in class Object

main

     public static void main(String argv[])

    All Packages  Class Hierarchy  This Package  Previous  Next  Index