all-up-in-your-elo 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +42 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/all-up-in-your-elo.gemspec +148 -0
- data/ext/bayeselo/.gitignore +4 -0
- data/ext/bayeselo/CBradleyTerry.cpp +670 -0
- data/ext/bayeselo/CBradleyTerry.h +137 -0
- data/ext/bayeselo/CCDistribution.cpp +135 -0
- data/ext/bayeselo/CCDistribution.h +44 -0
- data/ext/bayeselo/CCDistributionCUI.cpp +104 -0
- data/ext/bayeselo/CCDistributionCUI.h +38 -0
- data/ext/bayeselo/CCondensedResults.cpp +253 -0
- data/ext/bayeselo/CCondensedResults.h +64 -0
- data/ext/bayeselo/CDiscretization.h +40 -0
- data/ext/bayeselo/CDistribution.cpp +123 -0
- data/ext/bayeselo/CDistribution.h +58 -0
- data/ext/bayeselo/CDistributionCollection.cpp +34 -0
- data/ext/bayeselo/CDistributionCollection.h +29 -0
- data/ext/bayeselo/CEloRatingCUI.cpp +1046 -0
- data/ext/bayeselo/CEloRatingCUI.h +67 -0
- data/ext/bayeselo/CIndirectCompare.h +28 -0
- data/ext/bayeselo/CJointBayesian.cpp +111 -0
- data/ext/bayeselo/CJointBayesian.h +38 -0
- data/ext/bayeselo/CLUDecomposition.cpp +154 -0
- data/ext/bayeselo/CLUDecomposition.h +36 -0
- data/ext/bayeselo/CMatrix.cpp +48 -0
- data/ext/bayeselo/CMatrix.h +35 -0
- data/ext/bayeselo/CMatrixIO.cpp +27 -0
- data/ext/bayeselo/CMatrixIO.h +17 -0
- data/ext/bayeselo/CPredictionCUI.cpp +393 -0
- data/ext/bayeselo/CPredictionCUI.h +50 -0
- data/ext/bayeselo/CResultSet.cpp +245 -0
- data/ext/bayeselo/CResultSet.h +50 -0
- data/ext/bayeselo/CResultSetCUI.cpp +355 -0
- data/ext/bayeselo/CResultSetCUI.h +44 -0
- data/ext/bayeselo/CTimeIO.cpp +58 -0
- data/ext/bayeselo/CTimeIO.h +19 -0
- data/ext/bayeselo/CVector.cpp +110 -0
- data/ext/bayeselo/CVector.h +42 -0
- data/ext/bayeselo/EloDataFromFile.cpp +120 -0
- data/ext/bayeselo/EloDataFromFile.h +21 -0
- data/ext/bayeselo/README +8 -0
- data/ext/bayeselo/ReadLineToString.cpp +32 -0
- data/ext/bayeselo/ReadLineToString.h +18 -0
- data/ext/bayeselo/chtime.cpp +56 -0
- data/ext/bayeselo/chtime.h +61 -0
- data/ext/bayeselo/chtimer.h +27 -0
- data/ext/bayeselo/clktimer.cpp +178 -0
- data/ext/bayeselo/clktimer.h +29 -0
- data/ext/bayeselo/consolui.cpp +538 -0
- data/ext/bayeselo/consolui.h +154 -0
- data/ext/bayeselo/const.cpp +79 -0
- data/ext/bayeselo/const.h +42 -0
- data/ext/bayeselo/date.cpp +96 -0
- data/ext/bayeselo/date.h +44 -0
- data/ext/bayeselo/debug.h +58 -0
- data/ext/bayeselo/elomain.cpp +26 -0
- data/ext/bayeselo/eloratings.cpp +76 -0
- data/ext/bayeselo/extconf.rb +6 -0
- data/ext/bayeselo/list.h +367 -0
- data/ext/bayeselo/listi.h +125 -0
- data/ext/bayeselo/move.cpp +249 -0
- data/ext/bayeselo/move.h +139 -0
- data/ext/bayeselo/pgn.h +62 -0
- data/ext/bayeselo/pgnlex.cpp +432 -0
- data/ext/bayeselo/pgnlex.h +105 -0
- data/ext/bayeselo/pgnstr.cpp +126 -0
- data/ext/bayeselo/piece.h +44 -0
- data/ext/bayeselo/player.h +31 -0
- data/ext/bayeselo/position.h +89 -0
- data/ext/bayeselo/random.cpp +114 -0
- data/ext/bayeselo/random.h +63 -0
- data/ext/bayeselo/readstr.cpp +51 -0
- data/ext/bayeselo/readstr.h +19 -0
- data/ext/bayeselo/square.h +61 -0
- data/ext/bayeselo/str.cpp +81 -0
- data/ext/bayeselo/str.h +71 -0
- data/ext/bayeselo/version.cpp +30 -0
- data/ext/bayeselo/version.h +28 -0
- data/ext/bayeselo/version_number.h +1 -0
- data/lib/elo_ratings.rb +9 -0
- data/lib/elo_ratings/c_bayeselo.rb +5 -0
- data/lib/elo_ratings/results.rb +41 -0
- data/test/elo_ratings/test_c_bayeselo.rb +84 -0
- data/test/elo_ratings/test_results.rb +41 -0
- data/test/helper.rb +19 -0
- metadata +233 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
/////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// R�mi Coulom
|
4
|
+
//
|
5
|
+
// December, 2004
|
6
|
+
//
|
7
|
+
/////////////////////////////////////////////////////////////////////////////
|
8
|
+
#include "version.h"
|
9
|
+
#include "CResultSet.h"
|
10
|
+
#include "CResultSetCUI.h"
|
11
|
+
|
12
|
+
#include <iostream>
|
13
|
+
|
14
|
+
/////////////////////////////////////////////////////////////////////////////
|
15
|
+
// main function
|
16
|
+
/////////////////////////////////////////////////////////////////////////////
|
17
|
+
int main()
|
18
|
+
{
|
19
|
+
std::cout << CVersion::GetCopyright();
|
20
|
+
CResultSet rs;
|
21
|
+
std::vector<std::string> vecName;
|
22
|
+
CResultSetCUI rscui(rs, vecName);
|
23
|
+
rscui.MainLoop(std::cin, std::cout);
|
24
|
+
|
25
|
+
return 0;
|
26
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
// #include <ruby.h>
|
2
|
+
#include "rice/Class.hpp"
|
3
|
+
#include "rice/Data_Type.hpp"
|
4
|
+
#include "rice/Constructor.hpp"
|
5
|
+
#include "CBradleyTerry.h"
|
6
|
+
#include "CCondensedResults.h"
|
7
|
+
#include "CCDistribution.h"
|
8
|
+
#include "CResultSet.h"
|
9
|
+
|
10
|
+
|
11
|
+
using namespace Rice;
|
12
|
+
|
13
|
+
class CBayeselo
|
14
|
+
{
|
15
|
+
public:
|
16
|
+
CBayeselo();
|
17
|
+
void Append(unsigned w, unsigned b, unsigned r);
|
18
|
+
int GetPlayers();
|
19
|
+
int GetElo(int i);
|
20
|
+
float CountGames(int i);
|
21
|
+
private:
|
22
|
+
CResultSet rs;
|
23
|
+
};
|
24
|
+
|
25
|
+
CBayeselo::CBayeselo()
|
26
|
+
{
|
27
|
+
}
|
28
|
+
|
29
|
+
void CBayeselo::Append(unsigned w, unsigned b, unsigned r) {
|
30
|
+
rs.Append(w, b, r);
|
31
|
+
}
|
32
|
+
|
33
|
+
int CBayeselo::GetPlayers() {
|
34
|
+
return rs.GetPlayers();
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
int CBayeselo::GetElo(int i) {
|
39
|
+
CCondensedResults crs(rs);
|
40
|
+
crs.AddPrior(2.0); // CEloRating constructor
|
41
|
+
CBradleyTerry bt(crs);
|
42
|
+
|
43
|
+
//IDC_MM
|
44
|
+
int fThetaW = 0;
|
45
|
+
int fThetaD = 0;
|
46
|
+
bt.MinorizationMaximization(fThetaW, fThetaD);
|
47
|
+
|
48
|
+
// advantage 0
|
49
|
+
int eloAdvantage = 0;
|
50
|
+
bt.SetAdvantage(eloAdvantage);
|
51
|
+
|
52
|
+
// RoundDouble(double x)
|
53
|
+
double x = bt.GetElo(i);
|
54
|
+
if (x > 0)
|
55
|
+
return int(x+0.5);
|
56
|
+
else
|
57
|
+
return int(x-0.5);
|
58
|
+
}
|
59
|
+
|
60
|
+
float CBayeselo::CountGames(int i) {
|
61
|
+
return rs.CountGames(i);
|
62
|
+
}
|
63
|
+
|
64
|
+
extern "C"
|
65
|
+
void Init_elo_ratings()
|
66
|
+
{
|
67
|
+
Rice::Module mEloRatings = define_module("EloRatings");
|
68
|
+
|
69
|
+
Data_Type<CBayeselo> c_bayeselo =
|
70
|
+
define_class_under<CBayeselo>(mEloRatings, "CBayeselo")
|
71
|
+
.define_constructor(Constructor<CBayeselo>())
|
72
|
+
.define_method("get_players", &CBayeselo::GetPlayers)
|
73
|
+
.define_method("append", &CBayeselo::Append)
|
74
|
+
.define_method("get_elo", &CBayeselo::GetElo)
|
75
|
+
.define_method("count_games", &CBayeselo::CountGames);
|
76
|
+
}
|
data/ext/bayeselo/list.h
ADDED
@@ -0,0 +1,367 @@
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// list.h
|
4
|
+
//
|
5
|
+
// Remi Coulom
|
6
|
+
//
|
7
|
+
// april 1996
|
8
|
+
//
|
9
|
+
// list template
|
10
|
+
// efficient for small types (int, pointers, ...)
|
11
|
+
//
|
12
|
+
////////////////////////////////////////////////////////////////////////////
|
13
|
+
#ifndef LIST_H
|
14
|
+
#define LIST_H
|
15
|
+
|
16
|
+
#include "debug.h" // Debug macros (ASSERT, INLINE)
|
17
|
+
|
18
|
+
#ifdef LISTINLINE
|
19
|
+
#define BIGINLINE INLINE
|
20
|
+
#else
|
21
|
+
#define BIGINLINE
|
22
|
+
#endif
|
23
|
+
|
24
|
+
template<class T> class CListIterator;
|
25
|
+
template<class T> class CConstListIterator;
|
26
|
+
template<class T> class CListSort;
|
27
|
+
|
28
|
+
////////////////////////////////////////////////////////////////////////////
|
29
|
+
// CListCell class definition
|
30
|
+
////////////////////////////////////////////////////////////////////////////
|
31
|
+
template<class T>
|
32
|
+
class CListCell // cell
|
33
|
+
{
|
34
|
+
private:
|
35
|
+
T tValue;
|
36
|
+
CListCell<T> *pcellNext;
|
37
|
+
|
38
|
+
public:
|
39
|
+
T& Value() {return tValue;};
|
40
|
+
const T& Value() const {return tValue;};
|
41
|
+
|
42
|
+
CListCell<T> *Next() {return pcellNext;};
|
43
|
+
const CListCell<T> *Next() const {return pcellNext;};
|
44
|
+
|
45
|
+
void Link(CListCell<T> *pcell) {pcellNext = pcell;};
|
46
|
+
};
|
47
|
+
|
48
|
+
////////////////////////////////////////////////////////////////////////////
|
49
|
+
// CCellBloc class definition
|
50
|
+
////////////////////////////////////////////////////////////////////////////
|
51
|
+
template<class T>
|
52
|
+
class CCellBloc // bloc
|
53
|
+
{
|
54
|
+
private:
|
55
|
+
CListCell<T> *ptcell; // Array of cells
|
56
|
+
CCellBloc<T> *pblocNext; // Next bloc
|
57
|
+
|
58
|
+
public:
|
59
|
+
CCellBloc(int Size, CCellBloc<T> *pbloc);
|
60
|
+
~CCellBloc();
|
61
|
+
|
62
|
+
const CListCell<T> *FirstCell() const {return ptcell;};
|
63
|
+
CListCell<T> *FirstCell() {return ptcell;};
|
64
|
+
|
65
|
+
const CCellBloc<T> *Next() const {return pblocNext;};
|
66
|
+
CCellBloc<T> *Next() {return pblocNext;};
|
67
|
+
};
|
68
|
+
|
69
|
+
////////////////////////////////////////////////////////////////////////////
|
70
|
+
// CList class definition
|
71
|
+
////////////////////////////////////////////////////////////////////////////
|
72
|
+
template<class T>
|
73
|
+
class CList //lt
|
74
|
+
{
|
75
|
+
friend class CListIterator<T>;
|
76
|
+
friend class CConstListIterator<T>;
|
77
|
+
friend class CListSort<T>;
|
78
|
+
|
79
|
+
private: //////////////////////////////////////////////////////////////////
|
80
|
+
int BlocSize;
|
81
|
+
CListCell<T> *pcellFirst;
|
82
|
+
CListCell<T> *pcellFree;
|
83
|
+
CCellBloc<T> *pblocFirst;
|
84
|
+
|
85
|
+
void FreeCell(CListCell<T> *pcell);
|
86
|
+
CListCell<T> *AllocateCell();
|
87
|
+
|
88
|
+
public: ///////////////////////////////////////////////////////////////////
|
89
|
+
CList();
|
90
|
+
~CList();
|
91
|
+
CList(const CList<T> <);
|
92
|
+
CList<T> &operator=(const CList<T> <);
|
93
|
+
|
94
|
+
void Reset();
|
95
|
+
void Append(const CList<T> <);
|
96
|
+
void Add();
|
97
|
+
void Remove();
|
98
|
+
void SetBlocSize(int Size);
|
99
|
+
T& Head();
|
100
|
+
|
101
|
+
const T& Head() const;
|
102
|
+
int IsEmpty() const;
|
103
|
+
int GetSize() const;
|
104
|
+
};
|
105
|
+
|
106
|
+
////////////////////////////////////////////////////////////////////////////
|
107
|
+
// Constructor
|
108
|
+
////////////////////////////////////////////////////////////////////////////
|
109
|
+
template<class T>
|
110
|
+
CCellBloc<T>::CCellBloc(int Size, CCellBloc<T> *pbloc)
|
111
|
+
{
|
112
|
+
ASSERT(Size > 0);
|
113
|
+
pblocNext = pbloc;
|
114
|
+
ptcell = new CListCell<T>[Size];
|
115
|
+
|
116
|
+
{
|
117
|
+
for (int i = Size - 1; --i >= 0;)
|
118
|
+
ptcell[i].Link(&ptcell[i + 1]);
|
119
|
+
}
|
120
|
+
|
121
|
+
ptcell[Size - 1].Link(0);
|
122
|
+
}
|
123
|
+
|
124
|
+
////////////////////////////////////////////////////////////////////////////
|
125
|
+
// Destructor
|
126
|
+
////////////////////////////////////////////////////////////////////////////
|
127
|
+
template<class T>
|
128
|
+
inline
|
129
|
+
CCellBloc<T>::~CCellBloc()
|
130
|
+
{
|
131
|
+
delete[] ptcell;
|
132
|
+
}
|
133
|
+
|
134
|
+
////////////////////////////////////////////////////////////////////////////
|
135
|
+
// Constructor for CList<T>
|
136
|
+
////////////////////////////////////////////////////////////////////////////
|
137
|
+
template<class T>
|
138
|
+
BIGINLINE
|
139
|
+
CList<T>::CList()
|
140
|
+
{
|
141
|
+
pcellFirst = 0;
|
142
|
+
pcellFree = 0;
|
143
|
+
BlocSize = 1;
|
144
|
+
pblocFirst = 0;
|
145
|
+
}
|
146
|
+
|
147
|
+
////////////////////////////////////////////////////////////////////////////
|
148
|
+
// Copy constructor for CList<T>
|
149
|
+
////////////////////////////////////////////////////////////////////////////
|
150
|
+
template<class T>
|
151
|
+
CList<T>::CList(const CList<T> <)
|
152
|
+
{
|
153
|
+
BlocSize = lt.BlocSize;
|
154
|
+
|
155
|
+
pcellFirst = 0;
|
156
|
+
pcellFree = 0;
|
157
|
+
pblocFirst = 0;
|
158
|
+
|
159
|
+
Append(lt);
|
160
|
+
}
|
161
|
+
|
162
|
+
////////////////////////////////////////////////////////////////////////////
|
163
|
+
// Assignment operator
|
164
|
+
////////////////////////////////////////////////////////////////////////////
|
165
|
+
template<class T>
|
166
|
+
CList<T> &CList<T>::operator=(const CList<T> <)
|
167
|
+
{
|
168
|
+
if (< != this)
|
169
|
+
{
|
170
|
+
Reset();
|
171
|
+
BlocSize = lt.BlocSize;
|
172
|
+
Append(lt);
|
173
|
+
}
|
174
|
+
return *this;
|
175
|
+
}
|
176
|
+
|
177
|
+
////////////////////////////////////////////////////////////////////////////
|
178
|
+
// Destructor : deletes all the allocated memory
|
179
|
+
////////////////////////////////////////////////////////////////////////////
|
180
|
+
template<class T>
|
181
|
+
CList<T>::~CList()
|
182
|
+
{
|
183
|
+
Reset();
|
184
|
+
}
|
185
|
+
|
186
|
+
////////////////////////////////////////////////////////////////////////////
|
187
|
+
// Function called in destructor and assignment operator to free memory
|
188
|
+
////////////////////////////////////////////////////////////////////////////
|
189
|
+
template<class T>
|
190
|
+
void CList<T>::Reset()
|
191
|
+
{
|
192
|
+
CCellBloc<T> *pblocCurrent = pblocFirst;
|
193
|
+
|
194
|
+
while (pblocCurrent)
|
195
|
+
{
|
196
|
+
CCellBloc<T> *pblocNext = pblocCurrent->Next();
|
197
|
+
delete pblocCurrent;
|
198
|
+
pblocCurrent = pblocNext;
|
199
|
+
}
|
200
|
+
|
201
|
+
pcellFirst = 0;
|
202
|
+
pcellFree = 0;
|
203
|
+
pblocFirst = 0;
|
204
|
+
}
|
205
|
+
|
206
|
+
////////////////////////////////////////////////////////////////////////////
|
207
|
+
// Function to append a list at the end of a list
|
208
|
+
////////////////////////////////////////////////////////////////////////////
|
209
|
+
template<class T>
|
210
|
+
void CList<T>::Append(const CList<T> <)
|
211
|
+
{
|
212
|
+
if (lt.pcellFirst)
|
213
|
+
{
|
214
|
+
CListCell<T> *pcellCopy = AllocateCell();
|
215
|
+
|
216
|
+
//
|
217
|
+
// Allocation of a copy of the appended list
|
218
|
+
//
|
219
|
+
{
|
220
|
+
const CListCell<T> *pcellFrom = lt.pcellFirst;
|
221
|
+
CListCell<T> *pcellTo = pcellCopy;
|
222
|
+
|
223
|
+
do
|
224
|
+
{
|
225
|
+
pcellTo->Value() = pcellFrom->Value();
|
226
|
+
pcellFrom = pcellFrom->Next();
|
227
|
+
if (pcellFrom)
|
228
|
+
{
|
229
|
+
pcellTo->Link(AllocateCell());
|
230
|
+
pcellTo = pcellTo->Next();
|
231
|
+
}
|
232
|
+
else
|
233
|
+
pcellTo->Link(0);
|
234
|
+
}
|
235
|
+
while(pcellFrom);
|
236
|
+
}
|
237
|
+
|
238
|
+
//
|
239
|
+
// Search of the end of this list and addition of the copy
|
240
|
+
//
|
241
|
+
{
|
242
|
+
CListCell<T> *pcell = pcellFirst;
|
243
|
+
|
244
|
+
if (pcell)
|
245
|
+
{
|
246
|
+
while (pcell->Next())
|
247
|
+
pcell = pcell->Next();
|
248
|
+
pcell->Link(pcellCopy);
|
249
|
+
}
|
250
|
+
else
|
251
|
+
pcellFirst = pcellCopy;
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
////////////////////////////////////////////////////////////////////////////
|
257
|
+
// Adds a new cell at the beginning of the list
|
258
|
+
////////////////////////////////////////////////////////////////////////////
|
259
|
+
template<class T>
|
260
|
+
BIGINLINE
|
261
|
+
void CList<T>::Add()
|
262
|
+
{
|
263
|
+
CListCell<T> *pcellNew = AllocateCell();
|
264
|
+
ASSERT(!!pcellNew);
|
265
|
+
pcellNew->Link(pcellFirst);
|
266
|
+
pcellFirst = pcellNew;
|
267
|
+
}
|
268
|
+
|
269
|
+
////////////////////////////////////////////////////////////////////////////
|
270
|
+
// Deletes the head of the list
|
271
|
+
////////////////////////////////////////////////////////////////////////////
|
272
|
+
template<class T>
|
273
|
+
BIGINLINE
|
274
|
+
void CList<T>::Remove()
|
275
|
+
{
|
276
|
+
ASSERT(!IsEmpty());
|
277
|
+
CListCell<T> *pcell = pcellFirst;
|
278
|
+
pcellFirst = pcellFirst->Next();
|
279
|
+
FreeCell(pcell);
|
280
|
+
}
|
281
|
+
|
282
|
+
////////////////////////////////////////////////////////////////////////////
|
283
|
+
// Function to set the bloc size
|
284
|
+
////////////////////////////////////////////////////////////////////////////
|
285
|
+
template<class T>
|
286
|
+
void CList<T>::SetBlocSize(int Size)
|
287
|
+
{
|
288
|
+
ASSERT(Size > 0);
|
289
|
+
BlocSize = Size;
|
290
|
+
}
|
291
|
+
|
292
|
+
////////////////////////////////////////////////////////////////////////////
|
293
|
+
// Access to data at the head of the list
|
294
|
+
////////////////////////////////////////////////////////////////////////////
|
295
|
+
template<class T> // const version
|
296
|
+
INLINE
|
297
|
+
const T& CList<T>::Head() const
|
298
|
+
{
|
299
|
+
ASSERT(!IsEmpty());
|
300
|
+
return pcellFirst->Value();
|
301
|
+
}
|
302
|
+
template<class T> // non-const version
|
303
|
+
INLINE
|
304
|
+
T& CList<T>::Head()
|
305
|
+
{
|
306
|
+
ASSERT(!IsEmpty());
|
307
|
+
return pcellFirst->Value();
|
308
|
+
}
|
309
|
+
|
310
|
+
////////////////////////////////////////////////////////////////////////////
|
311
|
+
// Tests whether the list is empty
|
312
|
+
////////////////////////////////////////////////////////////////////////////
|
313
|
+
template<class T>
|
314
|
+
inline
|
315
|
+
int CList<T>::IsEmpty() const
|
316
|
+
{
|
317
|
+
return !pcellFirst;
|
318
|
+
}
|
319
|
+
|
320
|
+
////////////////////////////////////////////////////////////////////////////
|
321
|
+
// Frees one cell
|
322
|
+
////////////////////////////////////////////////////////////////////////////
|
323
|
+
template<class T>
|
324
|
+
inline
|
325
|
+
void CList<T>::FreeCell(CListCell<T> *pcell)
|
326
|
+
{
|
327
|
+
pcell->Link(pcellFree);
|
328
|
+
pcellFree = pcell;
|
329
|
+
}
|
330
|
+
|
331
|
+
////////////////////////////////////////////////////////////////////////////
|
332
|
+
// Count of list elements
|
333
|
+
////////////////////////////////////////////////////////////////////////////
|
334
|
+
template<class T>
|
335
|
+
int CList<T>::GetSize() const
|
336
|
+
{
|
337
|
+
CListCell<T> *pcell = pcellFirst;
|
338
|
+
int s = 0;
|
339
|
+
|
340
|
+
while (pcell)
|
341
|
+
{
|
342
|
+
s++;
|
343
|
+
pcell = pcell->Next();
|
344
|
+
}
|
345
|
+
|
346
|
+
return s;
|
347
|
+
}
|
348
|
+
|
349
|
+
////////////////////////////////////////////////////////////////////////////
|
350
|
+
// Allocates a new cell
|
351
|
+
////////////////////////////////////////////////////////////////////////////
|
352
|
+
template<class T>
|
353
|
+
BIGINLINE
|
354
|
+
CListCell<T> *CList<T>::AllocateCell()
|
355
|
+
{
|
356
|
+
if (!pcellFree)
|
357
|
+
{
|
358
|
+
pblocFirst = new CCellBloc<T>(BlocSize, pblocFirst);
|
359
|
+
pcellFree = pblocFirst->FirstCell();
|
360
|
+
}
|
361
|
+
|
362
|
+
CListCell<T> *pcell = pcellFree;
|
363
|
+
pcellFree = pcellFree->Next();
|
364
|
+
return pcell;
|
365
|
+
}
|
366
|
+
|
367
|
+
#endif
|