📄 array_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>array.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>array.h</h1><a href="array_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span>00002 <span class="comment"> * array.h</span>00003 <span class="comment"> *</span>00004 <span class="comment"> * Linear Array Container classes.</span>00005 <span class="comment"> *</span>00006 <span class="comment"> * Portable Windows Library</span>00007 <span class="comment"> *</span>00008 <span class="comment"> * Copyright (c) 1993-1998 Equivalence Pty. Ltd.</span>00009 <span class="comment"> *</span>00010 <span class="comment"> * The contents of this file are subject to the Mozilla Public License</span>00011 <span class="comment"> * Version 1.0 (the "License"); you may not use this file except in</span>00012 <span class="comment"> * compliance with the License. You may obtain a copy of the License at</span>00013 <span class="comment"> * http://www.mozilla.org/MPL/</span>00014 <span class="comment"> *</span>00015 <span class="comment"> * Software distributed under the License is distributed on an "AS IS"</span>00016 <span class="comment"> * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See</span>00017 <span class="comment"> * the License for the specific language governing rights and limitations</span>00018 <span class="comment"> * under the License.</span>00019 <span class="comment"> *</span>00020 <span class="comment"> * The Original Code is Portable Windows Library.</span>00021 <span class="comment"> *</span>00022 <span class="comment"> * The Initial Developer of the Original Code is Equivalence Pty. Ltd.</span>00023 <span class="comment"> *</span>00024 <span class="comment"> * Portions are Copyright (C) 1993 Free Software Foundation, Inc.</span>00025 <span class="comment"> * All Rights Reserved.</span>00026 <span class="comment"> *</span>00027 <span class="comment"> * Contributor(s): ______________________________________.</span>00028 <span class="comment"> *</span>00029 <span class="comment"> * $Log: array.h,v $</span>00030 <span class="comment"> * Revision 1.31 2004/05/13 02:07:14 dereksmithies</span>00031 <span class="comment"> * Fixes, so it works with doc++</span>00032 <span class="comment"> *</span>00033 <span class="comment"> * Revision 1.30 2004/04/09 03:42:34 csoutheren</span>00034 <span class="comment"> * Removed all usages of "virtual inline" and "inline virtual"</span>00035 <span class="comment"> *</span>00036 <span class="comment"> * Revision 1.29 2004/04/03 06:54:21 rjongbloed</span>00037 <span class="comment"> * Many and various changes to support new Visual C++ 2003</span>00038 <span class="comment"> *</span>00039 <span class="comment"> * Revision 1.28 2004/03/02 10:29:59 rjongbloed</span>00040 <span class="comment"> * Changed base array declaration macro to be consistent with the</span>00041 <span class="comment"> * object array one, thanks Guilhem Tardy</span>00042 <span class="comment"> *</span>00043 <span class="comment"> * Revision 1.27 2003/04/17 07:24:47 robertj</span>00044 <span class="comment"> * Fixed GNU 3.x problem (why no other compiler?)</span>00045 <span class="comment"> *</span>00046 <span class="comment"> * Revision 1.26 2003/04/15 07:08:36 robertj</span>00047 <span class="comment"> * Changed read and write from streams for base array classes so operates in</span>00048 <span class="comment"> * the same way for both PIntArray and PArray<int> etc</span>00049 <span class="comment"> *</span>00050 <span class="comment"> * Revision 1.25 2003/03/31 01:23:56 robertj</span>00051 <span class="comment"> * Added ReadFrom functions for standard container classes such as</span>00052 <span class="comment"> * PIntArray and PStringList etc</span>00053 <span class="comment"> *</span>00054 <span class="comment"> * Revision 1.24 2002/09/16 01:08:59 robertj</span>00055 <span class="comment"> * Added #define so can select if #pragma interface/implementation is used on</span>00056 <span class="comment"> * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.</span>00057 <span class="comment"> *</span>00058 <span class="comment"> * Revision 1.23 2002/06/20 06:08:59 robertj</span>00059 <span class="comment"> * Fixed GNU warning</span>00060 <span class="comment"> *</span>00061 <span class="comment"> * Revision 1.22 2002/06/14 13:20:37 robertj</span>00062 <span class="comment"> * Added PBitArray class.</span>00063 <span class="comment"> *</span>00064 <span class="comment"> * Revision 1.21 2002/02/14 23:37:53 craigs</span>00065 <span class="comment"> * Added fix for optimisation for PArray [] operator, thanks to Vyacheslav Frolov</span>00066 <span class="comment"> *</span>00067 <span class="comment"> * Revision 1.20 2002/02/14 05:11:50 robertj</span>00068 <span class="comment"> * Minor optimisation in the operator[] for arrays of PObjects.</span>00069 <span class="comment"> *</span>00070 <span class="comment"> * Revision 1.19 1999/11/30 00:22:54 robertj</span>00071 <span class="comment"> * Updated documentation for doc++</span>00072 <span class="comment"> *</span>00073 <span class="comment"> * Revision 1.18 1999/09/03 15:08:38 robertj</span>00074 <span class="comment"> * Fixed typo in ancestor class name</span>00075 <span class="comment"> *</span>00076 <span class="comment"> * Revision 1.17 1999/08/22 12:13:42 robertj</span>00077 <span class="comment"> * Fixed warning when using inlines on older GNU compiler</span>00078 <span class="comment"> *</span>00079 <span class="comment"> * Revision 1.16 1999/08/20 03:07:44 robertj</span>00080 <span class="comment"> * Fixed addded Concatenate function for non-template version.</span>00081 <span class="comment"> *</span>00082 <span class="comment"> * Revision 1.15 1999/08/18 01:45:12 robertj</span>00083 <span class="comment"> * Added concatenation function to "base type" arrays.</span>00084 <span class="comment"> *</span>00085 <span class="comment"> * Revision 1.14 1999/03/09 02:59:49 robertj</span>00086 <span class="comment"> * Changed comments to doc++ compatible documentation.</span>00087 <span class="comment"> *</span>00088 <span class="comment"> * Revision 1.13 1999/02/16 08:07:11 robertj</span>00089 <span class="comment"> * MSVC 6.0 compatibility changes.</span>00090 <span class="comment"> *</span>00091 <span class="comment"> * Revision 1.12 1998/09/23 06:20:16 robertj</span>00092 <span class="comment"> * Added open source copyright license.</span>00093 <span class="comment"> *</span>00094 <span class="comment"> * Revision 1.11 1998/08/21 05:23:57 robertj</span>00095 <span class="comment"> * Added hex dump capability to base array types.</span>00096 <span class="comment"> * Added ability to have base arrays of static memory blocks.</span>00097 <span class="comment"> *</span>00098 <span class="comment"> * Revision 1.10 1997/06/08 04:49:10 robertj</span>00099 <span class="comment"> * Fixed non-template class descendent order.</span>00100 <span class="comment"> *</span>00101 <span class="comment"> * Revision 1.9 1996/08/17 09:54:34 robertj</span>00102 <span class="comment"> * Optimised RemoveAll() for object arrays.</span>00103 <span class="comment"> *</span>00104 <span class="comment"> * Revision 1.8 1996/01/02 11:48:46 robertj</span>00105 <span class="comment"> * Removed requirement that PArray elements have parameterless constructor..</span>00106 <span class="comment"> *</span>00107 <span class="comment"> * Revision 1.7 1995/10/14 14:52:33 robertj</span>00108 <span class="comment"> * Changed arrays to not break references.</span>00109 <span class="comment"> *</span>00110 <span class="comment"> * Revision 1.6 1995/06/17 11:12:18 robertj</span>00111 <span class="comment"> * Documentation update.</span>00112 <span class="comment"> *</span>00113 <span class="comment"> * Revision 1.5 1995/03/14 12:40:58 robertj</span>00114 <span class="comment"> * Updated documentation to use HTML codes.</span>00115 <span class="comment"> *</span>00116 <span class="comment"> * Revision 1.4 1995/02/22 10:50:26 robertj</span>00117 <span class="comment"> * Changes required for compiling release (optimised) version.</span>00118 <span class="comment"> *</span>00119 <span class="comment"> * Revision 1.3 1995/01/15 04:49:09 robertj</span>00120 <span class="comment"> * Fixed errors in template version.</span>00121 <span class="comment"> *</span>00122 <span class="comment"> * Revision 1.2 1994/12/21 11:52:46 robertj</span>00123 <span class="comment"> * Documentation and variable normalisation.</span>00124 <span class="comment"> *</span>00125 <span class="comment"> * Revision 1.1 1994/12/12 09:59:29 robertj</span>00126 <span class="comment"> * Initial revision</span>00127 <span class="comment"> *</span>00128 <span class="comment"> */</span>00129 00130 <span class="preprocessor">#ifdef P_USE_PRAGMA</span>00131 <span class="preprocessor"></span><span class="preprocessor">#pragma interface</span>00132 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00133 <span class="preprocessor"></span>00135 <span class="comment">// The abstract array class</span>00136 <a name="l00158"></a><a class="code" href="classPAbstractArray.html">00158</a> <span class="keyword">class </span><a class="code" href="classPAbstractArray.html">PAbstractArray</a> : <span class="keyword">public</span> <a class="code" href="classPContainer.html">PContainer</a>00159 {00160 <a class="code" href="contain_8h.html#a0">PCONTAINERINFO</a>(<a class="code" href="classPAbstractArray.html">PAbstractArray</a>, <a class="code" href="classPContainer.html">PContainer</a>);00161 00162 <span class="keyword">public</span>:00174 <a class="code" href="classPAbstractArray.html#z19_0">PAbstractArray</a>(00175 PINDEX elementSizeInBytes,00179 PINDEX initialSize = 0 00180 );00181 00199 <a class="code" href="classPAbstractArray.html#z19_0">PAbstractArray</a>(00200 PINDEX elementSizeInBytes,00204 <span class="keyword">const</span> <span class="keywordtype">void</span> *buffer, 00205 PINDEX bufferSizeInElements, 00206 BOOL dynamicAllocation 00207 );00209 00218 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPAbstractArray.html#z21_0">PrintOn</a>(00219 ostream &strm <span class="comment">// Stream to print the object into.</span>00220 ) <span class="keyword">const</span>;00221 00228 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPAbstractArray.html#z21_1">ReadFrom</a>(00229 istream &strm <span class="comment">// Stream to read the objects contents from.</span>00230 );00231 00252 <span class="keyword">virtual</span> <a class="code" href="classPObject.html#z199_0">Comparison</a> <a class="code" href="classPAbstractArray.html#z21_2">Compare</a>(00253 <span class="keyword">const</span> <a class="code" href="classPObject.html">PObject</a> & obj 00254 ) <span class="keyword">const</span>;00256 00267 <span class="keyword">virtual</span> BOOL <a class="code" href="classPAbstractArray.html#z23_0">SetSize</a>(00268 PINDEX newSize 00269 );00271 00282 <span class="keywordtype">void</span> <a class="code" href="classPAbstractArray.html#z25_0">Attach</a>(00283 <span class="keyword">const</span> <span class="keywordtype">void</span> *buffer, 00284 PINDEX bufferSize 00285 );00286 00300 <span class="keywordtype">void</span> * <a class="code" href="classPAbstractArray.html#z25_1">GetPointer</a>(00301 PINDEX minSize = 1 00302 );00303 00316 BOOL <a class="code" href="classPAbstractArray.html#z25_2">Concatenate</a>(00317 <span class="keyword">const</span> <a class="code" href="classPAbstractArray.html">PAbstractArray</a> & array 00318 );00320 00321 <span class="keyword">protected</span>:00322 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPAbstractArray.html#b0">PrintElementOn</a>(00323 ostream & stream,00324 PINDEX index00325 ) <span class="keyword">const</span>;00326 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classPAbstractArray.html#b1">ReadElementFrom</a>(00327 istream & stream,00328 PINDEX index00329 );00330 <a name="l00332"></a><a class="code" href="classPAbstractArray.html#n0">00332</a> PINDEX <a class="code" href="classPAbstractArray.html#n0">elementSize</a>;00333 <a name="l00335"></a><a class="code" href="classPAbstractArray.html#n1">00335</a> <span class="keywordtype">char</span> * <a class="code" href="classPAbstractArray.html#n1">theArray</a>;00336 <a name="l00338"></a><a class="code" href="classPAbstractArray.html#n2">00338</a> BOOL <a class="code" href="classPAbstractArray.html#n2">allocatedDynamically</a>;00339 <a name="l00340"></a><a class="code" href="classPAbstractArray.html#l0">00340</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classPAbstractArray.html#l0">PArrayObjects</a>;00341 };00342 00343 00345 <span class="comment">// An array of some base type</span>00346 00347 <span class="preprocessor">#ifdef PHAS_TEMPLATES</span>00348 <span class="preprocessor"></span>00368 <span class="keyword">template</span> <<span class="keyword">class</span> T> <span class="keyword">class </span>PBaseArray : <span class="keyword">public</span> <a class="code" href="classPAbstractArray.html">PAbstractArray</a>00369 {00370 <a class="code" href="object_8h.html#a27">PCLASSINFO</a>(PBaseArray, <a class="code" href="classPAbstractArray.html">PAbstractArray</a>);00371 00372 <span class="keyword">public</span>:00380 PBaseArray(00381 PINDEX initialSize = 0 00382 ) : <a class="code" href="classPAbstractArray.html">PAbstractArray</a>(sizeof(T), initialSize) { }00383 00386 PBaseArray(00387 T <span class="keyword">const</span> * buffer, 00388 PINDEX length, 00389 BOOL dynamic = TRUE 00390 ) : <a class="code" href="classPAbstractArray.html">PAbstractArray</a>(sizeof(T), buffer, length, dynamic) { }00392 00397 <span class="keyword">virtual</span> <a class="code" href="classPObject.html">PObject</a> * <a class="code" href="classPObject.html#z203_0">Clone</a>()<span class="keyword"> const</span>00398 <span class="keyword"> </span>{ 00399 <span class="keywordflow">return</span> <a class="code" href="object_8h.html#a18">PNEW</a> PBaseArray<T>(*<span class="keyword">this</span>, <a class="code" href="classPContainer.html#z69_0">GetSize</a>());00400 }00402 00411 BOOL SetAt(00412 PINDEX index, 00413 T val 00414 ) {00415 <span class="keywordflow">return</span> <a class="code" href="classPContainer.html#z69_2">SetMinSize</a>(index+1) && val==(((T *)theArray)[index] = val);00416 }00417 00424 T GetAt(00425 PINDEX index 00426 )<span class="keyword"> const </span>{00427 PASSERTINDEX(index);00428 <span class="keywordflow">return</span> index < <a class="code" href="classPContainer.html#z69_0">GetSize</a>() ? ((T *)theArray)[index] : (T)0;00429 }00430 00439 <span class="keywordtype">void</span> <a class="code" href="classPAbstractArray.html#z25_0">Attach</a>(00440 <span class="keyword">const</span> T * buffer, 00441 PINDEX bufferSize 00442 ) {00443 <a class="code" href="classPAbstractArray.html#z25_0">PAbstractArray::Attach</a>(buffer, bufferSize);00444 }00445
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -