⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcontain.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
字号:
\section{Container classes overview}\label{wxcontaineroverview}Classes: \helpref{wxList}{wxlist}, \helpref{wxArray}{wxarray}wxWidgets uses itself several container classes including doubly-linked listsand dynamic arrays (i.e. arrays which expand automatically when they becomefull). For both historical and portability reasons wxWidgets does notuse STL which provides the standard implementation of many container classes inC++. First of all, wxWidgets has existed since well before STL was written, andsecondly we don't believe that today compilers can deal really well with all ofSTL classes (this is especially true for some less common platforms). Ofcourse, the compilers are evolving quite rapidly and hopefully their progresswill allow to base future versions of wxWidgets on STL - but this is not yetthe case.wxWidgets container classes don't pretend to be as powerful or full as STLones, but they are quite useful and may be compiled with absolutely any C++compiler. They're used internally by wxWidgets, but may, of course, be used inyour programs as well if you wish.The list classes in wxWidgets are doubly-linked lists which may either own theobjects they contain (meaning that the list deletes the object when it isremoved from the list or the list itself is destroyed) or just store thepointers depending on whether you called or not \helpref{wxList::DeleteContents}{wxlistdeletecontents} method.Dynamic arrays resemble C arrays but with two important differences: theyprovide run-time range checking in debug builds and they automatically expandthe allocated memory when there is no more space for new items. They come intwo sorts: the "plain" arrays which store either built-in types such as "char","int" or "bool" or the pointers to arbitrary objects, or "object arrays" whichown the object pointers to which they store.For the same portability reasons, the container classes implementation in wxWidgetsdoes not use templates, but is rather based on C preprocessor i.e. is done withthe macros: {\it WX\_DECLARE\_LIST} and {\it WX\_DEFINE\_LIST} for the linkedlists and {\it WX\_DECLARE\_ARRAY}, {\it WX\_DECLARE\_OBJARRAY} and {\it WX\_DEFINE\_OBJARRAY} forthe dynamic arrays. The "DECLARE" macro declares anew container class containing the elements of given type and is needed for allthree types of container classes: lists, arrays and objarrays. The "DEFINE"classes must be inserted in your program in a place where the {\bf fulldeclaration of container element class is in scope} (i.e. not just forwarddeclaration), otherwise destructors of the container elements will not becalled! As array classes never delete the items they contain anyhow, there isno WX\_DEFINE\_ARRAY macro for them.Examples of usage of these macros may be found in \helpref{wxList}{wxlist} and \helpref{wxArray}{wxarray} documentation.Finally, wxWidgets predefines several commonly used container classes. wxListis defined for compatibility with previous versions as a list containingwxObjects and wxStringList as a list of C-style strings (char *), both of theseclasses are deprecated and should not be used in new programs. The followingarray classes are defined: wxArrayInt, wxArrayLong, wxArrayPtrVoid andwxArrayString. The first three store elements of corresponding types, butwxArrayString is somewhat special: it is an optimized version of wxArray whichuses its knowledge about \helpref{wxString}{wxstring} reference countingschema.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -