blob: 0b353cb9e9d5c9d7680a037e0ffa0b078dd550de (
plain)
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
107
108
109
110
111
112
113
114
115
|
// File Aspect_GenId.cxx
// Created Mai 1992
// Author NW,JPB,CAL
//-Copyright MatraDatavision 1991,1992
//-Version
//-Design Declaration des variables specifiques aux identificateurs
//-Warning Un identificateur est un entier.
//-References
//-Language C++ 2.0
//-Declarations
// for the class
#include <Aspect_GenId.ixx>
//-Aliases
//-Global data definitions
//-Constructors
//-Destructors
//-Methods, in order
Aspect_GenId::Aspect_GenId ():
MyCount (INT_MAX/2 + 1),
MyLength (INT_MAX/2 + 1),
MyLowerBound (0),
MyUpperBound (INT_MAX/2),
MyFreeIds () {
}
Aspect_GenId::Aspect_GenId (const Standard_Integer Low, const Standard_Integer Up):MyFreeIds () {
if (Low <= Up) {
MyLowerBound = Low;
MyUpperBound = Up;
MyLength = MyUpperBound - MyLowerBound + 1;
MyCount = MyLength;
}
else
Aspect_IdentDefinitionError::Raise
("GenId Create Error: Low > Up");
}
Standard_Integer Aspect_GenId::Available () const {
return (MyCount);
}
void Aspect_GenId::Free () {
MyCount = MyLength;
MyFreeIds.Clear ();
}
void Aspect_GenId::Free (const Standard_Integer Id) {
if ( (Id >= MyLowerBound) && (Id <= MyUpperBound) )
MyFreeIds.Prepend (Id);
}
Standard_Integer Aspect_GenId::Lower () const {
return (MyLowerBound);
}
Standard_Integer Aspect_GenId::Next () {
if (MyCount == 0)
Aspect_IdentDefinitionError::Raise
("GenId Next Error: Available == 0");
Standard_Integer Id;
if (! MyFreeIds.IsEmpty ()) {
Id = MyFreeIds.First ();
MyFreeIds.RemoveFirst ();
}
else {
MyCount --;
Id = MyLowerBound + MyLength - MyCount - 1;
}
return Id;
}
Standard_Integer Aspect_GenId::Upper () const {
return (MyUpperBound);
}
//void Aspect_GenId::Assign (const Aspect_GenId& Other) {
//
// MyLowerBound = Other.Lower ();
// MyUpperBound = Other.Upper ();
//
//}
|