-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patharray.thh
More file actions
106 lines (99 loc) · 3.24 KB
/
array.thh
File metadata and controls
106 lines (99 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
20050125 ljz Added 'ReplaceAt()' to the 'Array' class
*/
/****************************************************************************
Copyright (C) 1995, University of California, Davis
THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND THE UNIVERSITY
OF CALIFORNIA DOES NOT MAKE ANY WARRANTY ABOUT THE SOFTWARE, ITS
PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY
SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF
THE SOFTWARE IS WITH THE USER.
Copyright of the software and supporting documentation is
owned by the University of California, and free access
is hereby granted as a license to use this software, copy this
software and prepare derivative works based upon this software.
However, any distribution of this software source code or
supporting documentation or derivative works (source code and
supporting documentation) must include this copyright notice.
****************************************************************************/
/***************************************************************************
*
* University of California, Davis
* UCDMC DICOM Network Transport Libraries
* Version 0.1 Beta
*
* Technical Contact: mhoskin@ucdavis.edu
*
***************************************************************************/
/*********************************************************************
* Array Unit Class
*
* ANSI (ARM) C++ Compatible / Templates Required
*
*
* usage:
*
* # include "array.thh"
* # include "array.tcc"
*
*
* Array<ClassType> VarName;
*
*
*********************************************************************/
template <class DATATYPE>
class DataLink
{
public:
DATATYPE Data;
DataLink<DATATYPE> *prev, *next;
DataLink(DataLink<DATATYPE> *p, DataLink<DATATYPE> *n)
{ prev = p; next = n; };
DataLink()
{ prev = NULL; next = NULL; };
};
template <class DATATYPE>
class Array
{
public:
DataLink<DATATYPE> *first;
DataLink<DATATYPE> *last;
DataLink<DATATYPE> *LastAccess;
unsigned int LastAccessNumber;
unsigned int ArraySize;
public:
UINT ClearType;
DATATYPE & Add(DATATYPE &);
DATATYPE & Get(unsigned int);
DATATYPE & ReplaceAt(DATATYPE &, unsigned int);
BOOL RemoveAt(unsigned int);
BOOL Clear ()
{
first = last = LastAccess = NULL;
LastAccessNumber = 0;
ArraySize = 0;
return ( TRUE );
}
#ifdef MAC
DATATYPE & operator [] (unsigned int Index)
{ return(Get(Index)); };
unsigned int GetSize()
{ return(ArraySize); };
#else
inline DATATYPE & operator [] (unsigned int Index)
{ return(Get(Index)); };
inline unsigned int GetSize()
{ return(ArraySize); };
#endif
Array()
{ ArraySize = 0; first = NULL; last = NULL; LastAccess = NULL; LastAccessNumber = 0; ClearType = 1; };
Array(UINT);
#ifdef MAC
~Array();
#else
virtual ~Array();
#endif
void operator = (Array<DATATYPE> &array)
{ first = array.first; last = array.last; ArraySize = array.ArraySize; ClearType = FALSE; };
};