CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

csStringArray Class Reference

An array of strings. More...

#include <csutil/stringarray.h>

Inheritance diagram for csStringArray:

csArray< const char *, csStringArrayElementHandler > List of all members.

Public Member Functions

 csStringArray (int ilimit=0, int ithreshold=0)
 Initialize object to hold initially 'ilimit' elements, and increase storage by 'ithreshold' each time the upper bound is exceeded.
void Sort (int(*compare)(char const *const &, char const *const &))
 Sort array based on comparison function.
void Sort (bool case_sensitive=true)
 Sort array.
size_t FindSortedKey (csArrayCmp< char const *, char const * > comparekey, size_t *candidate=0) const
 Find an element based on some key, using a comparison function.
size_t FindSortedKey (char const *key, bool case_sensitive=true, size_t *candidate=0) const
 Find an element.
size_t InsertSorted (const char *item, bool case_sensitive=true, size_t *equal_index=0)
 Insert an element at a sorted position.
char * Pop ()
 Pop an element from tail end of array.
size_t Find (const char *what) const
 Find a string, case-sensitive.
size_t FindCaseInsensitive (const char *what) const
 Find a string, case-insensitive.

Detailed Description

An array of strings.

This array will properly make copies of the strings and delete those copies using delete[] later.

Definition at line 51 of file stringarray.h.


Constructor & Destructor Documentation

csStringArray::csStringArray int  ilimit = 0,
int  ithreshold = 0
[inline]
 

Initialize object to hold initially 'ilimit' elements, and increase storage by 'ithreshold' each time the upper bound is exceeded.

Definition at line 59 of file stringarray.h.


Member Function Documentation

size_t csStringArray::Find const char *  what  )  const [inline]
 

Find a string, case-sensitive.

Returns -1 if not found, else item index. Works with unsorted arrays. For sorted arrays, FindSortedKey() is faster.

Definition at line 150 of file stringarray.h.

References csArray< const char *, csStringArrayElementHandler >::Length().

size_t csStringArray::FindCaseInsensitive const char *  what  )  const [inline]
 

Find a string, case-insensitive.

Returns -1 if not found, else item index. Works with unsorted arrays. For sorted arrays, FindSortedKey() is faster.

Definition at line 162 of file stringarray.h.

References csStrCaseCmp(), and csArray< const char *, csStringArrayElementHandler >::Length().

size_t csStringArray::FindSortedKey char const *  key,
bool  case_sensitive = true,
size_t *  candidate = 0
const [inline]
 

Find an element.

The array must be sorted. Returns -1 if element does not exist.

Definition at line 109 of file stringarray.h.

References FindSortedKey().

size_t csStringArray::FindSortedKey csArrayCmp< char const *, char const * >  comparekey,
size_t *  candidate = 0
const [inline]
 

Find an element based on some key, using a comparison function.

The array must be sorted. Returns -1 if element does not exist.

Definition at line 99 of file stringarray.h.

Referenced by FindSortedKey().

size_t csStringArray::InsertSorted const char *  item,
bool  case_sensitive = true,
size_t *  equal_index = 0
[inline]
 

Insert an element at a sorted position.

Assumes array is already sorted.

Definition at line 123 of file stringarray.h.

char* csStringArray::Pop  )  [inline]
 

Pop an element from tail end of array.

Caller is responsible for invoking delete[] on the returned string when no longer needed.

Reimplemented from csArray< const char *, csStringArrayElementHandler >.

Definition at line 136 of file stringarray.h.

References csArray< const char *, csStringArrayElementHandler >::Get(), csArray< const char *, csStringArrayElementHandler >::InitRegion(), csArray< const char *, csStringArrayElementHandler >::Length(), and csArray< const char *, csStringArrayElementHandler >::SetLength().

void csStringArray::Sort bool  case_sensitive = true  )  [inline]
 

Sort array.

Definition at line 87 of file stringarray.h.

References Sort().

void csStringArray::Sort int(*)(char const *const &, char const *const &)  compare  )  [inline]
 

Sort array based on comparison function.

Definition at line 79 of file stringarray.h.

Referenced by Sort().


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.3.9.1