]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/container.h
removed wxAcceleratorTable copy ctor docs, no port implements it
[wxWidgets.git] / docs / doxygen / overviews / container.h
CommitLineData
15b6757b 1/////////////////////////////////////////////////////////////////////////////
d54cf7ff 2// Name: container.h
15b6757b
FM
3// Purpose: topic overview
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
880efa2a 9/**
36c9828f 10
880efa2a 11@page overview_container Container Classes
36c9828f 12
880efa2a 13Classes: wxList<T>, wxArray<T>, wxVector<T>
d54cf7ff 14
880efa2a
BP
15wxWidgets uses itself several container classes including doubly-linked lists
16and dynamic arrays (i.e. arrays which expand automatically when they become
17full). For both historical and portability reasons wxWidgets does not use STL
18which provides the standard implementation of many container classes in C++.
d54cf7ff 19
880efa2a
BP
20First of all, wxWidgets has existed since well before STL was written, and
21secondly we don't believe that today compilers can deal really well with all of
22STL classes (this is especially true for some less common platforms). Of
23course, the compilers are evolving quite rapidly and hopefully their progress
24will allow to base future versions of wxWidgets on STL - but this is not yet
25the case.
d54cf7ff 26
880efa2a
BP
27wxWidgets container classes don't pretend to be as powerful or full as STL
28ones, but they are quite useful and may be compiled with absolutely any C++
29compiler. They're used internally by wxWidgets, but may, of course, be used in
30your programs as well if you wish.
d54cf7ff 31
880efa2a
BP
32The list classes in wxWidgets are doubly-linked lists which may either own the
33objects they contain (meaning that the list deletes the object when it is
34removed from the list or the list itself is destroyed) or just store the
35pointers depending on whether or not you called wxList<T>::DeleteContents()
36method.
d54cf7ff 37
880efa2a
BP
38Dynamic arrays resemble C arrays but with two important differences: they
39provide run-time range checking in debug builds and they automatically expand
40the allocated memory when there is no more space for new items. They come in
41two sorts: the "plain" arrays which store either built-in types such as "char",
42"int" or "bool" or the pointers to arbitrary objects, or "object arrays" which
43own the object pointers to which they store.
d54cf7ff 44
880efa2a
BP
45For the same portability reasons, the container classes implementation in
46wxWidgets does not use templates, but is rather based on C preprocessor i.e. is
47done with the macros: WX_DECLARE_LIST() and WX_DEFINE_LIST() for the linked
48lists and WX_DECLARE_ARRAY(), WX_DECLARE_OBJARRAY() and WX_DEFINE_OBJARRAY()
49for the dynamic arrays.
d54cf7ff 50
880efa2a
BP
51The "DECLARE" macro declares a new container class containing the elements of
52given type and is needed for all three types of container classes: lists,
53arrays and objarrays. The "DEFINE" classes must be inserted in your program in
54a place where the @e full declaration of container element class is in scope
55(i.e. not just forward declaration), otherwise destructors of the container
56elements will not be called!
d54cf7ff 57
880efa2a
BP
58As array classes never delete the items they contain anyhow, there is no
59WX_DEFINE_ARRAY() macro for them.
d54cf7ff 60
880efa2a
BP
61Examples of usage of these macros may be found in wxList<T> and wxArray<T>
62documentation.
d54cf7ff 63
880efa2a
BP
64Finally, wxWidgets predefines several commonly used container classes. wxList
65is defined for compatibility with previous versions as a list containing
66wxObjects and wxStringList as a list of C-style strings (char *), both of these
67classes are deprecated and should not be used in new programs. The following
68array classes are defined: wxArrayInt, wxArrayLong, wxArrayPtrVoid and
69wxArrayString. The first three store elements of corresponding types, but
70wxArrayString is somewhat special: it is an optimized version of wxArray which
71uses its knowledge about wxString reference counting schema.
36c9828f 72
d54cf7ff 73*/
880efa2a 74