org.basex.util.list
Class StringList

java.lang.Object
  extended by org.basex.util.list.ElementList
      extended by org.basex.util.list.StringList
All Implemented Interfaces:
java.lang.Iterable<java.lang.String>

public class StringList
extends ElementList
implements java.lang.Iterable<java.lang.String>

This is a simple container for strings.

Author:
BaseX Team 2005-13, BSD License, Christian Gruen

Field Summary
protected  java.lang.String[] list
          Element container.
 
Fields inherited from class org.basex.util.list.ElementList
factor, size
 
Constructor Summary
StringList()
          Default constructor.
StringList(int capacity)
          Constructor, specifying an initial internal array size.
StringList(java.lang.String... elements)
          Lightweight constructor, assigning the specified array.
 
Method Summary
 StringList add(java.lang.String... elements)
          Adds elements to the array.
 StringList add(java.lang.String e)
          Adds an element to the array.
 StringList add(StringList elements)
          Adds elements from a string list to the array.
 boolean contains(java.lang.String element)
          Checks if the specified element is found in the list.
 boolean containsAll(StringList elements)
          Check if all elements of the specified list are contained in the list.
 void deleteAt(int index)
          Deletes the specified element.
 java.lang.String get(int index)
          Returns the element at the specified position.
 java.util.Iterator<java.lang.String> iterator()
           
 java.lang.String peek()
          Returns the uppermost element from the stack.
 java.lang.String pop()
          Pops the uppermost element from the stack.
 void push(java.lang.String element)
          Pushes an element onto the stack.
 void set(int index, java.lang.String element)
          Sets an element at the specified index position.
 StringList sort(boolean cs)
          Sorts the elements in ascending order.
 StringList sort(boolean cs, boolean asc)
          Sorts the elements.
 StringList sort(boolean cs, boolean asc, int index)
          Sorts the elements.
 java.lang.String[] toArray()
          Returns an array with all elements.
 java.lang.String toString()
           
 StringList unique()
          Removes duplicates from the list.
 
Methods inherited from class org.basex.util.list.ElementList
isEmpty, newSize, newSize, reset, size, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list

protected java.lang.String[] list
Element container.

Constructor Detail

StringList

public StringList()
Default constructor.


StringList

public StringList(int capacity)
Constructor, specifying an initial internal array size.

Parameters:
capacity - initial array capacity

StringList

public StringList(java.lang.String... elements)
Lightweight constructor, assigning the specified array.

Parameters:
elements - initial array
Method Detail

add

public final StringList add(java.lang.String e)
Adds an element to the array.

Parameters:
e - element to be added
Returns:
self reference

add

public final StringList add(java.lang.String... elements)
Adds elements to the array.

Parameters:
elements - elements to be added
Returns:
self reference

add

public final StringList add(StringList elements)
Adds elements from a string list to the array.

Parameters:
elements - string list to be added
Returns:
self reference

get

public final java.lang.String get(int index)
Returns the element at the specified position.

Parameters:
index - element index
Returns:
element

set

public final void set(int index,
                      java.lang.String element)
Sets an element at the specified index position.

Parameters:
index - index
element - element to be set

contains

public final boolean contains(java.lang.String element)
Checks if the specified element is found in the list.

Parameters:
element - element to be found
Returns:
result of check

containsAll

public final boolean containsAll(StringList elements)
Check if all elements of the specified list are contained in the list. Both lists must be sorted.

Parameters:
elements - sorted list
Returns:
result of check

deleteAt

public final void deleteAt(int index)
Deletes the specified element.

Parameters:
index - index of element to be deleted

toArray

public final java.lang.String[] toArray()
Returns an array with all elements.

Returns:
array

sort

public final StringList sort(boolean cs)
Sorts the elements in ascending order.

Parameters:
cs - respect case sensitivity
Returns:
self reference

sort

public final StringList sort(boolean cs,
                             boolean asc)
Sorts the elements.

Parameters:
cs - respect case sensitivity
asc - ascending/descending flag
Returns:
self reference

sort

public final StringList sort(boolean cs,
                             boolean asc,
                             int index)
Sorts the elements.

Parameters:
cs - respect case sensitivity
asc - ascending (true)/descending (false) flag
index - index of element from which sorting starts
Returns:
self reference

unique

public StringList unique()
Removes duplicates from the list. The list must be sorted.

Returns:
self reference

peek

public final java.lang.String peek()
Returns the uppermost element from the stack.

Returns:
the uppermost element

pop

public final java.lang.String pop()
Pops the uppermost element from the stack.

Returns:
the popped element

push

public final void push(java.lang.String element)
Pushes an element onto the stack.

Parameters:
element - element

iterator

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

toString

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