1 | /***************************************************************************** |
2 | |
3 | DynArray.h |
4 | Copyright (c) 2005 Laurent de Soras |
5 | |
6 | --- Legal stuff --- |
7 | |
8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Lesser General Public |
10 | License as published by the Free Software Foundation; either |
11 | version 2.1 of the License, or (at your option) any later version. |
12 | |
13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Lesser General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Lesser General Public |
19 | License along with this library; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | |
22 | *Tab=3***********************************************************************/ |
23 | |
24 | |
25 | |
26 | #if ! defined (DynArray_HEADER_INCLUDED) |
27 | #define |
28 | |
29 | #if defined (_MSC_VER) |
30 | #pragma once |
31 | #pragma warning (4 : 4250) // "Inherits via dominance." |
32 | #endif |
33 | |
34 | |
35 | |
36 | /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
37 | |
38 | |
39 | |
40 | template <class T> |
41 | class DynArray |
42 | { |
43 | |
44 | /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
45 | |
46 | public: |
47 | |
48 | typedef T DataType; |
49 | |
50 | DynArray (); |
51 | explicit DynArray (long size); |
52 | ~DynArray (); |
53 | |
54 | inline long size () const; |
55 | inline void resize (long size); |
56 | |
57 | inline const DataType & |
58 | operator [] (long pos) const; |
59 | inline DataType & |
60 | operator [] (long pos); |
61 | |
62 | |
63 | |
64 | /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
65 | |
66 | protected: |
67 | |
68 | |
69 | |
70 | /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
71 | |
72 | private: |
73 | |
74 | DataType * _data_ptr; |
75 | long _len; |
76 | |
77 | |
78 | |
79 | /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
80 | |
81 | private: |
82 | |
83 | DynArray (const DynArray &other); |
84 | DynArray & operator = (const DynArray &other); |
85 | bool operator == (const DynArray &other); |
86 | bool operator != (const DynArray &other); |
87 | |
88 | }; // class DynArray |
89 | |
90 | |
91 | |
92 | #include "DynArray.hpp" |
93 | |
94 | |
95 | |
96 | #endif // DynArray_HEADER_INCLUDED |
97 | |
98 | |
99 | |
100 | /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ |
101 | |