C++ Portable Types Library (PTypes) Version 1.7

Top: Basic types: Lists: strlist

The strlist class is a dynamic array of strings, optionally sorted. A pointer to an object derived from unknown can be associated with each string of the string list, thus, string lists can be used as containers of either strings, objects, or string/object pairs. Strlist itself is derived from unknown.

If a string list was constructed with SL_SORTED flag, then strings or string/object pairs are kept in alphabetical order. Whether the sorting is case sensitive or not can also be specified during construction. Keeping the list sorted assures that a string or an object associated with a string can be found relatively faster.

When an item is removed from the list, or the entire list is cleared (using clear() function) or destroyed, the objects associated with strings are not freed from memory unless the option SL_OWNOBJECTS is specified. "Owning objects" means the string list is responsible for destroying and freeing its member objects.

A class template named tstrlist, fully compatible with strlist, is provided for better type checking at compile time. If you declare a variable, for example, of type tstrlist<myclass>, all manipulation functions for this variable will accept and return pointers to myclass, instead of unknown.

This class is declared in <ptypes.h> header file.

See also: unknown, Constructors/destructors, Manipulation, Search

PTypes home