tsc_StringList

A list of tsc_String objects.  This class is lightweight, and in general should not be created using new.  To pass a reference to a tsc_StringList, use a reference or pointer.  Passing by value will create a new list.

Because tsc_String is immutable and reference-counted, there are no difficulties with allocation, deallocation and ownership of the strings in the list; everything just works as it does with a .NET List<String>.

Note that copies of the list using assignment (=) or the copy constructor will create a new list.  The strings themselves, being immutable, will be referenced but not copied.

 

tsc_StringList ();
Constructs an empty list.

tsc_StringList (int capacity);
Constructs an empty list preallocated to the given capacity.  If additions to the list exceed this capacity, the list will grow automatically.

tsc_StringList (const char* s1, const char* s2 = NULL, ... , const char* s10 = NULL);
Creates a string list containing between one and ten string items.  This is simply a convenience for creating small lists of constant strings.  The supplied strings are added to the list in order until the first NULL is encountered.

tsc_StringList (const tsc_StringList &strings, int capacity=0);
Copies from another list, then increases the capacity to the given value.  capacity is ignored if it is less than the size of the list.

tsc_StringList& operator= (const tsc_StringList &strings);
Makes a new list containing the supplied strings.

tsc_StringList operator+ (const tsc_String &string) const
Makes a copy of the list with the supplied string appended. To avoid copying the list, use +=.

tsc_StringList operator+ (const tsc_StringList &strings) const
Makes a copy of the list with the supplied strings appended. To avoid copying the list, use +=.

tsc_StringList& operator+= (const tsc_String &string);
Appends a string to the list.

tsc_StringList& operator+= (const char *string);
Appends a string to the list.

tsc_StringList& operator+= (const tsc_StringList &strings);
Appends the strings to the list.

const tsc_String& operator[] (int index) const
Returns the string at the given zero-based index.

tsc_String & operator[] (int index);
Returns the string at the given zero-based index.

bool operator== (const tsc_StringList &strings);
True if each string is equal in both lists.|

bool operator!= (const tsc_StringList &strings);
False if the supplied list contains the same string values.

void Append (const tsc_String &string);
Adds a string to the end of the list.

void Insert (int index, const tsc_String &string);
Inserts a string at index.

void Remove (int index);
Removes the string at index and moves all following strings to fill the gap.

int Count () const
Returns the count of strings in the list.

void Clear ();
Removes all strings from the list, deallocates all memory, and resets the capacity to zero.

bool    IsEmpty();
Returns true if there are no entries.

int IndexOf (const tsc_String &string, tsc_CaseOptions options = Case_Sensitive) const
Returns the zero-based index of the first matching string, or -1 if no match was found.

bool Contains (const tsc_String &string, tsc_CaseOptions options = Case_Sensitive) const
Returns true if the list contains a string that matches the supplied string.

void Sort (tsc_CaseOptions options = Case_Sensitive);
Sorts the list in ascending order of string contents.