Skip to content

Commit f173112

Browse files
author
Alan Wright
committed
Now able to use the default std::allocator instead of the custom Allocator.
1 parent c6e5192 commit f173112

15 files changed

+289
-279
lines changed

bin/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

include/BitSet.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ namespace Lucene
1717
public:
1818
BitSet(uint32_t size = 0);
1919
virtual ~BitSet();
20-
20+
2121
LUCENE_CLASS(BitSet);
22-
22+
2323
protected:
24-
typedef boost::dynamic_bitset< uint64_t, Allocator<uint64_t> > bitset_type;
24+
typedef boost::dynamic_bitset< uint64_t, LuceneAllocator<uint64_t> > bitset_type;
2525
bitset_type bitSet;
26-
26+
2727
public:
2828
const uint64_t* getBits();
2929
void clear();
@@ -56,7 +56,7 @@ namespace Lucene
5656
bool intersectsBitSet(BitSetPtr set) const;
5757
uint32_t cardinality();
5858
void resize(uint32_t size);
59-
59+
6060
virtual bool equals(LuceneObjectPtr other);
6161
virtual int32_t hashCode();
6262
virtual LuceneObjectPtr clone(LuceneObjectPtr other = LuceneObjectPtr());

include/Collection.h

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,289 +19,289 @@ namespace Lucene
1919
public:
2020
typedef Collection<TYPE> this_type;
2121
typedef boost::shared_ptr<this_type> shared_ptr;
22-
typedef std::vector< TYPE, Allocator<TYPE> > collection_type;
22+
typedef std::vector< TYPE, LuceneAllocator<TYPE> > collection_type;
2323
typedef typename collection_type::iterator iterator;
2424
typedef typename collection_type::const_iterator const_iterator;
2525
typedef TYPE value_type;
26-
26+
2727
virtual ~Collection()
2828
{
2929
}
30-
30+
3131
protected:
3232
boost::shared_ptr<collection_type> container;
33-
33+
3434
public:
3535
static this_type newInstance(int32_t size = 0)
3636
{
3737
this_type instance;
3838
instance.container = Lucene::newInstance<collection_type>(size);
3939
return instance;
4040
}
41-
41+
4242
template <class ITER>
4343
static this_type newInstance(ITER first, ITER last)
4444
{
4545
this_type instance;
4646
instance.container = Lucene::newInstance<collection_type>(first, last);
4747
return instance;
4848
}
49-
49+
5050
void reset()
5151
{
5252
resize(0);
5353
}
54-
54+
5555
void resize(int32_t size)
5656
{
5757
if (size == 0)
5858
container.reset();
5959
else
6060
container->resize(size);
6161
}
62-
62+
6363
int32_t size() const
6464
{
6565
return (int32_t)container->size();
6666
}
67-
67+
6868
bool empty() const
6969
{
7070
return container->empty();
7171
}
72-
72+
7373
void clear()
7474
{
7575
container->clear();
7676
}
77-
77+
7878
iterator begin()
7979
{
8080
return container->begin();
8181
}
82-
82+
8383
iterator end()
8484
{
8585
return container->end();
8686
}
87-
87+
8888
const_iterator begin() const
8989
{
9090
return container->begin();
9191
}
92-
92+
9393
const_iterator end() const
9494
{
9595
return container->end();
9696
}
97-
97+
9898
void add(const TYPE& type)
9999
{
100100
container->push_back(type);
101101
}
102-
102+
103103
void add(int32_t pos, const TYPE& type)
104104
{
105105
container->insert(container->begin() + pos, type);
106106
}
107-
107+
108108
template <class ITER>
109109
void addAll(ITER first, ITER last)
110110
{
111111
container->insert(container->end(), first, last);
112112
}
113-
113+
114114
template <class ITER>
115115
void insert(ITER pos, const TYPE& type)
116116
{
117117
container->insert(pos, type);
118118
}
119-
119+
120120
template <class ITER>
121121
ITER remove(ITER pos)
122122
{
123123
return container->erase(pos);
124124
}
125-
125+
126126
template <class ITER>
127127
ITER remove(ITER first, ITER last)
128128
{
129129
return container->erase(first, last);
130130
}
131-
131+
132132
void remove(const TYPE& type)
133133
{
134134
container->erase(std::remove(container->begin(), container->end(), type), container->end());
135135
}
136-
136+
137137
template <class PRED>
138138
void remove_if(PRED comp)
139139
{
140140
container->erase(std::remove_if(container->begin(), container->end(), comp), container->end());
141141
}
142-
142+
143143
TYPE removeFirst()
144144
{
145145
TYPE front = container->front();
146146
container->erase(container->begin());
147147
return front;
148148
}
149-
149+
150150
TYPE removeLast()
151151
{
152152
TYPE back = container->back();
153153
container->pop_back();
154154
return back;
155155
}
156-
156+
157157
iterator find(const TYPE& type)
158158
{
159159
return std::find(container->begin(), container->end(), type);
160160
}
161-
161+
162162
template <class PRED>
163163
iterator find_if(PRED comp)
164164
{
165165
return std::find_if(container->begin(), container->end(), comp);
166166
}
167-
167+
168168
bool contains(const TYPE& type) const
169169
{
170170
return (std::find(container->begin(), container->end(), type) != container->end());
171171
}
172-
172+
173173
template <class PRED>
174174
bool contains_if(PRED comp) const
175175
{
176176
return (std::find_if(container->begin(), container->end(), comp) != container->end());
177177
}
178-
178+
179179
bool equals(const this_type& other) const
180180
{
181181
return equals(other, std::equal_to<TYPE>());
182182
}
183-
183+
184184
template <class PRED>
185185
bool equals(const this_type& other, PRED comp) const
186186
{
187187
if (container->size() != other.container->size())
188188
return false;
189189
return std::equal(container->begin(), container->end(), other.container->begin(), comp);
190190
}
191-
191+
192192
int32_t hashCode()
193193
{
194194
return (int32_t)(int64_t)container.get();
195195
}
196-
196+
197197
void swap(this_type& other)
198198
{
199199
container.swap(other->container);
200200
}
201-
201+
202202
TYPE& operator[] (int32_t pos)
203203
{
204204
return (*container)[pos];
205205
}
206-
206+
207207
const TYPE& operator[] (int32_t pos) const
208208
{
209209
return (*container)[pos];
210210
}
211-
211+
212212
operator bool() const
213213
{
214214
return container;
215215
}
216-
216+
217217
bool operator! () const
218218
{
219219
return !container;
220220
}
221-
221+
222222
bool operator== (const this_type& other)
223223
{
224224
return (container == other.container);
225225
}
226-
226+
227227
bool operator!= (const this_type& other)
228228
{
229229
return (container != other.container);
230230
}
231231
};
232-
232+
233233
template <typename TYPE>
234234
Collection<TYPE> newCollection(const TYPE& a1)
235235
{
236236
Collection<TYPE> result = Collection<TYPE>::newInstance();
237237
result.add(a1);
238238
return result;
239239
}
240-
240+
241241
template <typename TYPE>
242242
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2)
243243
{
244244
Collection<TYPE> result = newCollection(a1);
245245
result.add(a2);
246246
return result;
247247
}
248-
248+
249249
template <typename TYPE>
250250
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2, const TYPE& a3)
251251
{
252252
Collection<TYPE> result = newCollection(a1, a2);
253253
result.add(a3);
254254
return result;
255255
}
256-
256+
257257
template <typename TYPE>
258258
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2, const TYPE& a3, const TYPE& a4)
259259
{
260260
Collection<TYPE> result = newCollection(a1, a2, a3);
261261
result.add(a4);
262262
return result;
263263
}
264-
264+
265265
template <typename TYPE>
266266
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2, const TYPE& a3, const TYPE& a4, const TYPE& a5)
267267
{
268268
Collection<TYPE> result = newCollection(a1, a2, a3, a4);
269269
result.add(a5);
270270
return result;
271271
}
272-
272+
273273
template <typename TYPE>
274274
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2, const TYPE& a3, const TYPE& a4, const TYPE& a5, const TYPE& a6)
275275
{
276276
Collection<TYPE> result = newCollection(a1, a2, a3, a4, a5);
277277
result.add(a6);
278278
return result;
279279
}
280-
280+
281281
template <typename TYPE>
282282
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2, const TYPE& a3, const TYPE& a4, const TYPE& a5, const TYPE& a6, const TYPE& a7)
283283
{
284284
Collection<TYPE> result = newCollection(a1, a2, a3, a4, a5, a6);
285285
result.add(a7);
286286
return result;
287287
}
288-
288+
289289
template <typename TYPE>
290290
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2, const TYPE& a3, const TYPE& a4, const TYPE& a5, const TYPE& a6, const TYPE& a7, const TYPE& a8)
291291
{
292292
Collection<TYPE> result = newCollection(a1, a2, a3, a4, a5, a6, a7);
293293
result.add(a8);
294294
return result;
295295
}
296-
296+
297297
template <typename TYPE>
298298
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2, const TYPE& a3, const TYPE& a4, const TYPE& a5, const TYPE& a6, const TYPE& a7, const TYPE& a8, const TYPE& a9)
299299
{
300300
Collection<TYPE> result = newCollection(a1, a2, a3, a4, a5, a6, a7, a8);
301301
result.add(a9);
302302
return result;
303303
}
304-
304+
305305
template <typename TYPE>
306306
Collection<TYPE> newCollection(const TYPE& a1, const TYPE& a2, const TYPE& a3, const TYPE& a4, const TYPE& a5, const TYPE& a6, const TYPE& a7, const TYPE& a8, const TYPE& a9, const TYPE& a10)
307307
{

include/Config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
// Define to enable cyclic checking in debug builds
7878
// #define LPP_USE_CYCLIC_CHECK
7979

80+
// Define to use custom allocator (useful in Windows builds and when using nedmalloc)
81+
#define LPP_USE_ALLOCATOR
82+
8083
// Define to use nedmalloc memory allocator
8184
// #define LPP_USE_NEDMALLOC
8285

0 commit comments

Comments
 (0)