@@ -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 {
0 commit comments