dRonin
adbada4
dRonin GCS
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Groups
Pages
DynArray.hpp
Go to the documentation of this file.
1
/*****************************************************************************
2
3
DynArray.hpp
4
By Laurent de Soras
5
6
--- Legal stuff ---
7
8
This program is free software. It comes without any warranty, to
9
the extent permitted by applicable law. You can redistribute it
10
and/or modify it under the terms of the Do What The Fuck You Want
11
To Public License, Version 2, as published by Sam Hocevar. See
12
http://sam.zoy.org/wtfpl/COPYING for more details.
13
14
*Tab=3***********************************************************************/
15
16
17
18
#if defined (ffft_DynArray_CURRENT_CODEHEADER)
19
#error Recursive inclusion of DynArray code header.
20
#endif
21
#define ffft_DynArray_CURRENT_CODEHEADER
22
23
#if ! defined (ffft_DynArray_CODEHEADER_INCLUDED)
24
#define ffft_DynArray_CODEHEADER_INCLUDED
25
26
27
28
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
29
30
#include <cassert>
31
32
33
34
namespace
ffft
35
{
36
37
38
39
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
40
41
42
43
template
<
class
T>
44
DynArray <T>::DynArray
()
45
: _data_ptr (0)
46
, _len (0)
47
{
48
// Nothing
49
}
50
51
52
53
template
<
class
T>
54
DynArray <T>::DynArray
(
long
size)
55
: _data_ptr (0)
56
, _len (0)
57
{
58
assert (size >= 0);
59
if
(size > 0)
60
{
61
_data_ptr =
new
DataType
[size];
62
_len = size;
63
}
64
}
65
66
67
68
template
<
class
T>
69
DynArray <T>
::~DynArray ()
70
{
71
delete
[] _data_ptr;
72
_data_ptr = 0;
73
_len = 0;
74
}
75
76
77
78
template
<
class
T>
79
long
DynArray <T>::size
()
const
80
{
81
return
(_len);
82
}
83
84
85
86
template
<
class
T>
87
void
DynArray <T>::resize
(
long
size)
88
{
89
assert (size >= 0);
90
if
(size > 0)
91
{
92
DataType
* old_data_ptr = _data_ptr;
93
DataType
* tmp_data_ptr =
new
DataType
[size];
94
95
_data_ptr = tmp_data_ptr;
96
_len = size;
97
98
delete
[] old_data_ptr;
99
}
100
}
101
102
103
104
template
<
class
T>
105
const
typename
DynArray <T>::DataType
&
DynArray <T>::operator
[] (
long
pos)
const
106
{
107
assert (pos >= 0);
108
assert (pos < _len);
109
110
return
(_data_ptr [pos]);
111
}
112
113
114
115
template
<
class
T>
116
typename
DynArray <T>::DataType
&
DynArray <T>::operator
[] (
long
pos)
117
{
118
assert (pos >= 0);
119
assert (pos < _len);
120
121
return
(_data_ptr [pos]);
122
}
123
124
125
126
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
127
128
129
130
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
131
132
133
134
}
// namespace ffft
135
136
137
138
#endif // ffft_DynArray_CODEHEADER_INCLUDED
139
140
#undef ffft_DynArray_CURRENT_CODEHEADER
141
142
143
144
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
ffft::DynArray::DataType
T DataType
Definition:
DynArray.h:35
ffft::DynArray
Definition:
DynArray.h:29
ground
gcs
src
libs
ffft
DynArray.hpp
Generated by
1.8.6