-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathimplicitItemId.cc
More file actions
101 lines (83 loc) · 2.39 KB
/
implicitItemId.cc
File metadata and controls
101 lines (83 loc) · 2.39 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
#include "clstepcore/implicitItemId.h"
Implicit_item_id::Implicit_item_id() {
_local_definition = 0;
}
Implicit_item_id::Implicit_item_id( Implicit_item_id & iii )
: Interfaced_item( iii ) {
_local_definition = iii._local_definition;
}
Implicit_item_id::~Implicit_item_id() {
_local_definition = 0;
}
Implicit_item_id__set::Implicit_item_id__set( int defaultSize ) {
_bufsize = defaultSize;
_buf = new Implicit_item_id_ptr[_bufsize];
_count = 0;
}
Implicit_item_id__set::~Implicit_item_id__set() {
delete[] _buf;
}
void Implicit_item_id__set::Check( int index ) {
Implicit_item_id_ptr * newbuf;
if( index >= _bufsize ) {
_bufsize = ( index + 1 ) * 2;
newbuf = new Implicit_item_id_ptr[_bufsize];
memmove( newbuf, _buf, _count * sizeof( Implicit_item_id_ptr ) );
delete[]_buf;
_buf = newbuf;
}
}
void Implicit_item_id__set::Insert( Implicit_item_id_ptr v, int index ) {
Implicit_item_id_ptr * spot;
index = ( index < 0 ) ? _count : index;
if( index < _count ) {
Check( _count + 1 );
spot = &_buf[index];
memmove( spot + 1, spot, ( _count - index )*sizeof( Implicit_item_id_ptr ) );
} else {
Check( index );
spot = &_buf[index];
}
*spot = v;
++_count;
}
void Implicit_item_id__set::Append( Implicit_item_id_ptr v ) {
int index = _count;
Implicit_item_id_ptr * spot;
if( index < _count ) {
Check( _count + 1 );
spot = &_buf[index];
memmove( spot + 1, spot, ( _count - index )*sizeof( Implicit_item_id_ptr ) );
} else {
Check( index );
spot = &_buf[index];
}
*spot = v;
++_count;
}
void Implicit_item_id__set::Remove( int index ) {
if( 0 <= index && index < _count ) {
--_count;
Implicit_item_id_ptr * spot = &_buf[index];
memmove( spot, spot + 1, ( _count - index )*sizeof( Implicit_item_id_ptr ) );
}
}
int Implicit_item_id__set::Index( Implicit_item_id_ptr v ) {
for( int i = 0; i < _count; ++i ) {
if( _buf[i] == v ) {
return i;
}
}
return -1;
}
Implicit_item_id_ptr & Implicit_item_id__set::operator[]( int index ) {
Check( index );
_count = ( ( _count > index + 1 ) ? _count : ( index + 1 ) );
return _buf[index];
}
int Implicit_item_id__set::Count() {
return _count;
}
void Implicit_item_id__set::Clear() {
_count = 0;
}