CrystalSpace

Public API Reference

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

csStringArray Class Reference

An array of strings. More...

#include <stringarray.h>

Inheritance diagram for csStringArray:

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

Public Methods

 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.

int FindSortedKey (csArrayCmpDecl(char const *, char const *) comparekey, int *candidate=0) const
 Find an element based on some key, using a comparison function.

int FindSortedKey (char const *key, bool case_sensitive=true, int *candidate=0) const
 Find an element.

char * Pop ()
 Pop an element from tail end of array.

int Find (const char *what) const
 Find a string, case-sensitive.

int 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

int 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 136 of file stringarray.h.

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

int 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 148 of file stringarray.h.

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

int csStringArray::FindSortedKey char const *    key,
bool    case_sensitive = true,
int *    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().

int csStringArray::FindSortedKey csArrayCmpDecl(char const *, char const *)    comparekey,
int *    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().

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.

Definition at line 122 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(*    compare)(char const *const &, char const *const &) [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.2.18