vdk 2.4.0
Main Page
Related Pages
Classes
Files
File List
vdk
container.h
1
/*
2
* ===========================
3
* VDK Visual Develeopment Kit
4
* Version 0.4
5
* October 1998
6
* ===========================
7
*
8
* Copyright (C) 1998, Mario Motta
9
* Developed by Mario Motta <mmotta@guest.net>
10
*
11
* This library is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Library General Public
13
* License as published by the Free Software Foundation; either
14
* version 2 of the License, or (at your option) any later version.
15
*
16
* This library is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Library General Public License for more details.
20
*
21
* You should have received a copy of the GNU Library General Public
22
* License along with this library; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24
* 02111-1307, USA.
25
*/
26
27
#ifndef CONTAINER_H
28
#define CONTAINER_H
29
/*******************
30
* Class VDKContainer *
31
*******************/
36
template
<
class
T>
37
class
VDKContainer
38
{
39
protected
:
40
T* data;
41
int
count;
42
public
:
47
VDKContainer
(
int
count=0):
48
data(count > 0 ? new T[count]: 0),
49
count(count)
50
{
51
}
52
53
virtual
~
VDKContainer
()
54
{
55
if
(data)
56
delete
[] data;
57
}
61
T&
operator[]
(
int
n)
62
{
63
return
data[n];
64
}
68
int
size
(){
return
count;}
72
VDKContainer
(
const
VDKContainer<T>
& c);
76
VDKContainer<T>
&
operator=
(
const
VDKContainer<T>
& c);
80
int
operator ==
(
const
VDKContainer<T>
& c);
81
82
};
83
84
85
template
<
class
T>
86
VDKContainer<T>::VDKContainer
(
const
VDKContainer<T>
& c)
87
{
88
data=0;
89
*
this
=c;
90
}
91
92
93
template
<
class
T>
94
VDKContainer<T>
&
VDKContainer<T>::operator=
(
const
VDKContainer<T>
& c)
95
{
96
if
(
this
!= &c)
97
{
98
if
(data)
delete
[]data;
99
count=c.count;
100
data= count >0 ?
new
T[count]:0;
101
for
(
int
i=0;i<count;i++)
102
data[i]=c.data[i];
103
}
104
return
*
this
;
105
}
106
107
108
template
<
class
T>
109
int
VDKContainer<T>::operator ==
(
const
VDKContainer<T>
& c)
110
{
111
int
i=0;
112
if
(count!=c.count)
return
0;
113
for
(;(i<count) && (data[i]==c.data[i]);i++);
114
return
i==count ?1:0;
115
}
116
117
#endif
118
119
120
Generated on Wed Mar 12 2014 15:03:43 for vdk 2.4.0 by
1.8.1.2