foobar2000 SDK  2015-08-03
list.h
Go to the documentation of this file.
1 #ifndef _PFC_LIST_H_
2 #define _PFC_LIST_H_
3 
4 namespace pfc {
5 
6 template<typename T>
7 class NOVTABLE list_base_const_t {
8 private: typedef list_base_const_t<T> t_self;
9 public:
10  typedef T t_item;
11  virtual t_size get_count() const = 0;
12  virtual void get_item_ex(T& p_out, t_size n) const = 0;
13 
14  inline t_size get_size() const {return get_count();}
15 
16  inline T get_item(t_size n) const {T temp; get_item_ex(temp,n); return std::move(temp);}
17  inline T operator[](t_size n) const {T temp; get_item_ex(temp,n); return std::move(temp);}
18 
19  template<typename t_compare>
20  t_size find_duplicates_sorted_t(t_compare p_compare,bit_array_var & p_out) const
21  {
22  return ::pfc::find_duplicates_sorted_t<list_base_const_t<T> const &,t_compare>(*this,get_count(),p_compare,p_out);
23  }
24 
25  template<typename t_compare,typename t_permutation>
26  t_size find_duplicates_sorted_permutation_t(t_compare p_compare,t_permutation const & p_permutation,bit_array_var & p_out)
27  {
28  return ::pfc::find_duplicates_sorted_permutation_t<list_base_const_t<T> const &,t_compare,t_permutation>(*this,get_count(),p_compare,p_permutation,p_out);
29  }
30 
31  template<typename t_search>
32  t_size find_item(const t_search & p_item) const//returns index of first occurance, infinite if not found
33  {
34  t_size n,max = get_count();
35  for(n=0;n<max;n++)
36  if (get_item(n)==p_item) return n;
37  return ~0;
38  }
39 
40  template<typename t_search>
41  inline bool have_item(const t_search & p_item) const {return find_item<t_search>(p_item)!=~0;}
42 
43 
44  template<typename t_compare, typename t_param>
45  bool bsearch_t(t_compare p_compare,t_param const & p_param,t_size &p_index) const {
46  return ::pfc::bsearch_t(get_count(),*this,p_compare,p_param,p_index);
47  }
48 
49  template<typename t_compare,typename t_param,typename t_permutation>
50  bool bsearch_permutation_t(t_compare p_compare,t_param const & p_param,const t_permutation & p_permutation,t_size & p_index) const {
51  return ::pfc::bsearch_permutation_t(get_count(),*this,p_compare,p_param,p_permutation,p_index);
52  }
53 
54  template<typename t_compare,typename t_permutation>
55  void sort_get_permutation_t(t_compare p_compare,t_permutation const & p_permutation) const {
56  ::pfc::sort_get_permutation_t<list_base_const_t<T>,t_compare,t_permutation>(*this,p_compare,get_count(),p_permutation);
57  }
58 
59  template<typename t_compare,typename t_permutation>
60  void sort_stable_get_permutation_t(t_compare p_compare,t_permutation const & p_permutation) const {
61  ::pfc::sort_stable_get_permutation_t<list_base_const_t<T>,t_compare,t_permutation>(*this,p_compare,get_count(),p_permutation);
62  }
63 
64  template<typename t_callback>
65  void enumerate(t_callback & p_callback) const {
66  for(t_size n = 0, m = get_count(); n < m; ++n ) {
67  p_callback( (*this)[n] );
68  }
69  }
70 
71  static bool g_equals(const t_self & item1, const t_self & item2) {
72  const t_size count = item1.get_count();
73  if (count != item2.get_count()) return false;
74  for(t_size walk = 0; walk < count; ++walk) if (item1[walk] != item2[walk]) return false;
75  return true;
76  }
77  bool operator==(const t_self & item2) const {return g_equals(*this,item2);}
78  bool operator!=(const t_self & item2) const {return !g_equals(*this,item2);}
79 
80 protected:
83 
84  list_base_const_t(const t_self &) {}
85  void operator=(const t_self &) {}
86 
87 };
88 
89 
90 template<typename T>
92 {
93 public:
94  list_single_ref_t(const T & p_item,t_size p_count = 1) : m_item(p_item), m_count(p_count) {}
95  t_size get_count() const {return m_count;}
96  void get_item_ex(T& p_out,t_size n) const {PFC_ASSERT(n<m_count); p_out = m_item;}
97 private:
98  const T & m_item;
100 };
101 
102 template<typename T>
104 {
105 public:
106  list_partial_ref_t(const list_base_const_t<T> & p_list,t_size p_base,t_size p_count)
107  : m_list(p_list), m_base(p_base), m_count(p_count)
108  {
109  PFC_ASSERT(m_base + m_count <= m_list.get_count());
110  }
111 
112 private:
114  t_size m_base,m_count;
115 
116  t_size get_count() const {return m_count;}
117  void get_item_ex(T & p_out,t_size n) const {m_list.get_item_ex(p_out,n+m_base);}
118 };
119 
120 template<typename T,typename A>
122 {
123 public:
124  inline list_const_array_t(A p_data,t_size p_count) : m_data(p_data), m_count(p_count) {}
125  t_size get_count() const {return m_count;}
126  void get_item_ex(T & p_out,t_size n) const {p_out = m_data[n];}
127 private:
130 };
131 template<typename t_array>
132 class list_const_array_ref_t : public list_base_const_t<typename t_array::t_item> {
133 public:
134  list_const_array_ref_t(const t_array & data) : m_data(data) {}
135  t_size get_count() const {return m_data.get_size();}
136  void get_item_ex(typename t_array::t_item & out, t_size n) const {out = m_data[n];}
137 private:
138  const t_array & m_data;
139 };
140 
141 template<typename to,typename from>
143 {
144 public:
145  list_const_cast_t(const list_base_const_t<from> & p_from) : m_from(p_from) {}
146  t_size get_count() const {return m_from.get_count();}
147  void get_item_ex(to & p_out,t_size n) const
148  {
149  from temp;
150  m_from.get_item_ex(temp,n);
151  p_out = temp;
152  }
153 private:
155 };
156 
157 template<typename T,typename A>
159 {
160 public:
161  inline ptr_list_const_array_t(A p_data,t_size p_count) : m_data(p_data), m_count(p_count) {}
162  t_size get_count() const {return m_count;}
163  void get_item_ex(T* & p_out,t_size n) const {p_out = &m_data[n];}
164 private:
167 };
168 template<typename T>
170 {
171 public:
172  inline list_const_ptr_t(const T * p_data,t_size p_count) : m_data(p_data), m_count(p_count) {}
173  t_size get_count() const {return m_count;}
174  void get_item_ex(T & p_out,t_size n) const {p_out = m_data[n];}
175 private:
176  const T * m_data;
178 };
179 
180 template<typename T>
181 class NOVTABLE list_base_t : public list_base_const_t<T> {
182 private:
185 public:
186  class NOVTABLE sort_callback
187  {
188  public:
189  virtual int compare(const T& p_item1,const T& p_item2) = 0;
190  };
191 
192  virtual void filter_mask(const bit_array & mask) = 0;
193  virtual t_size insert_items(const list_base_const_t<T> & items,t_size base) = 0;
194  virtual void reorder_partial(t_size p_base,const t_size * p_data,t_size p_count) = 0;
195  virtual void sort(sort_callback & p_callback) = 0;
196  virtual void sort_stable(sort_callback & p_callback) = 0;
197  virtual void replace_item(t_size p_index,const T& p_item) = 0;
198  virtual void swap_item_with(t_size p_index,T & p_item) = 0;
199  virtual void swap_items(t_size p_index1,t_size p_index2) = 0;
200 
201  inline void reorder(const t_size * p_data) {reorder_partial(0,p_data,this->get_count());}
202 
203  inline t_size insert_item(const T & item,t_size base) {return insert_items(list_single_ref_t<T>(item),base);}
204  t_size insert_items_repeat(const T & item,t_size num,t_size base) {return insert_items(list_single_ref_t<T>(item,num),base);}
205  inline t_size add_items_repeat(T item,t_size num) {return insert_items_repeat(item,num,~0);}
206  t_size insert_items_fromptr(const T* source,t_size num,t_size base) {return insert_items(list_const_ptr_t<T>(source,num),base);}
207  inline t_size add_items_fromptr(const T* source,t_size num) {return insert_items_fromptr(source,num,~0);}
208 
209  inline t_size add_items(const list_base_const_t<T> & items) {return insert_items(items,~0);}
210  inline t_size add_item(const T& item) {return insert_item(item,~0);}
211 
212  inline void remove_mask(const bit_array & mask) {filter_mask(bit_array_not(mask));}
213  inline void remove_all() {filter_mask(bit_array_false());}
214  inline void truncate(t_size val) {if (val < this->get_count()) remove_mask(bit_array_range(val,this->get_count()-val,true));}
215 
216  inline T replace_item_ex(t_size p_index,const T & p_item) {T ret = p_item;swap_item_with(p_index,ret);return ret;}
217 
218  inline T operator[](t_size n) const {return this->get_item(n);}
219 
220  template<typename t_compare>
222  {
223  public:
224  sort_callback_impl_t(t_compare p_compare) : m_compare(p_compare) {}
225  int compare(const T& p_item1,const T& p_item2) {return m_compare(p_item1,p_item2);}
226  private:
227  t_compare m_compare;
228  };
229 
231  {
232  public:
233  int compare(const T& p_item1,const T& p_item2) {return ::pfc::compare_t(p_item1,p_item2);}
234  };
235 
236  void sort() {sort(sort_callback_auto());}
237  template<typename t_compare> void sort_t(t_compare p_compare) {sort(sort_callback_impl_t<t_compare>(p_compare));}
238  template<typename t_compare> void sort_stable_t(t_compare p_compare) {sort_stable(sort_callback_impl_t<t_compare>(p_compare));}
239 
240  template<typename t_compare> void sort_remove_duplicates_t(t_compare p_compare)
241  {
242  sort_t<t_compare>(p_compare);
243  bit_array_bittable array(this->get_count());
244  if (this->template find_duplicates_sorted_t<t_compare>(p_compare,array) > 0)
245  remove_mask(array);
246  }
247 
248  template<typename t_compare> void sort_stable_remove_duplicates_t(t_compare p_compare)
249  {
250  sort_stable_t<t_compare>(p_compare);
251  bit_array_bittable array(this->get_count());
252  if (this->template find_duplicates_sorted_t<t_compare>(p_compare,array) > 0)
253  remove_mask(array);
254  }
255 
256 
257  template<typename t_compare> void remove_duplicates_t(t_compare p_compare)
258  {
259  order_helper order(this->get_count());
260  sort_get_permutation_t<t_compare,order_helper&>(p_compare,order);
261  bit_array_bittable array(this->get_count());
262  if (this->template find_duplicates_sorted_permutation_t<t_compare,order_helper const&>(p_compare,order,array) > 0)
263  remove_mask(array);
264  }
265 
266  template<typename t_func>
267  void for_each(t_func p_func) {
268  t_size n,max=this->get_count();
269  for(n=0;n<max;n++) p_func(this->get_item(n));
270  }
271 
272  template<typename t_func>
273  void for_each(t_func p_func,const bit_array & p_mask) {
274  t_size n,max=this->get_count();
275  for(n=p_mask.find(true,0,max);n<max;n=p_mask.find(true,n+1,max-n-1)) {
276  p_func(this->get_item(n));
277  }
278  }
279 
280  template<typename t_releasefunc>
281  void remove_mask_ex(const bit_array & p_mask,t_releasefunc p_func) {
282  this->template for_each<t_releasefunc>(p_func,p_mask);
283  remove_mask(p_mask);
284  }
285 
286  template<typename t_releasefunc>
287  void remove_all_ex(t_releasefunc p_func) {
288  this->template for_each<t_releasefunc>(p_func);
289  remove_all();
290  }
291 
292  template<typename t_in> t_self & operator=(t_in const & source) {remove_all(); add_items(source); return *this;}
293  template<typename t_in> t_self & operator+=(t_in const & p_source) {add_item(p_source); return *this;}
294  template<typename t_in> t_self & operator|=(t_in const & p_source) {add_items(p_source); return *this;}
295 
296 protected:
299  list_base_t(const t_self&) {}
300  void operator=(const t_self&) {}
301 };
302 
303 
304 template<typename T,typename t_storage>
306 {
307 public:
311  list_impl_t(const t_self & p_source) { add_items(p_source); }
312 
313  void prealloc(t_size count) {m_buffer.prealloc(count);}
314 
315  void set_count(t_size p_count) {m_buffer.set_size(p_count);}
316  void set_size(t_size p_count) {m_buffer.set_size(p_count);}
317 
318  template<typename t_in>
319  t_size _insert_item_t(const t_in & item, t_size idx) {
320  return ::pfc::insert_t(m_buffer, item, idx);
321  }
322  template<typename t_in>
323  t_size insert_item(const t_in & item, t_size idx) {
324  return _insert_item_t(item, idx);
325  }
326 
327  t_size insert_item(const T& item,t_size idx) {
328  return _insert_item_t(item, idx);
329  }
330 
332  {
333  T ret = m_buffer[idx];
334  t_size n;
335  t_size max = m_buffer.get_size();
336  for(n=idx+1;n<max;n++) {
337  ::pfc::move_t(m_buffer[n-1],m_buffer[n]);
338  }
339  m_buffer.set_size(max-1);
340  return ret;
341  }
342 
343 
344  inline void get_item_ex(T& p_out,t_size n) const
345  {
346  PFC_ASSERT(n>=0);
347  PFC_ASSERT(n<get_size());
348  p_out = m_buffer[n];
349  }
350 
351  inline const T& get_item_ref(t_size n) const
352  {
353  PFC_ASSERT(n>=0);
354  PFC_ASSERT(n<get_size());
355  return m_buffer[n];
356  }
357 
358  inline T get_item(t_size n) const
359  {
360  PFC_ASSERT(n >= 0);
361  PFC_ASSERT(n < get_size() );
362  return m_buffer[n];
363  };
364 
365  inline t_size get_count() const {return m_buffer.get_size();}
366  inline t_size get_size() const {return m_buffer.get_size();}
367 
368  inline const T & operator[](t_size n) const
369  {
370  PFC_ASSERT(n>=0);
371  PFC_ASSERT(n<get_size());
372  return m_buffer[n];
373  }
374 
375  inline const T* get_ptr() const {return m_buffer.get_ptr();}
376  inline T* get_ptr() {return m_buffer.get_ptr();}
377 
378  inline T& operator[](t_size n) {return m_buffer[n];}
379 
380  inline void remove_from_idx(t_size idx,t_size num)
381  {
382  remove_mask(bit_array_range(idx,num));
383  }
384 
385  t_size _insert_items_v(const list_base_const_t<T> & source,t_size base) { //workaround for inefficient operator[] on virtual-interface-accessed lists
386  t_size count = get_size();
387  if (base>count) base = count;
388  t_size num = source.get_count();
389  m_buffer.set_size(count+num);
390  if (count > base) {
391  for(t_size n=count-1;(int)n>=(int)base;n--) {
392  ::pfc::move_t(m_buffer[n+num],m_buffer[n]);
393  }
394  }
395 
396  for(t_size n=0;n<num;n++) {
397  source.get_item_ex(m_buffer[n+base],n);
398  }
399  return base;
400  }
401  // use _insert_items_v where it's more efficient
402  t_size insert_items(const list_base_const_t<T> & source,t_size base) {return _insert_items_v(source, base);}
403  t_size insert_items(const list_base_t<T> & source,t_size base) {return _insert_items_v(source, base);}
404 
405  template<typename t_in>
406  t_size insert_items(const t_in & source,t_size base) {
407  t_size count = get_size();
408  if (base>count) base = count;
409  t_size num = array_size_t(source);
410  m_buffer.set_size(count+num);
411  if (count > base) {
412  for(t_size n=count-1;(int)n>=(int)base;n--) {
413  ::pfc::move_t(m_buffer[n+num],m_buffer[n]);
414  }
415  }
416 
417  for(t_size n=0;n<num;n++) {
418  m_buffer[n+base] = source[n];
419  }
420  return base;
421  }
422 
423  template<typename t_in>
424  void add_items(const t_in & in) {insert_items(in, ~0);}
425 
427  {
428  t_size n,count = get_size();
429  for_each_bit_array(n,mask,true,0,count)
430  out.add_item(m_buffer[n]);
431  }
432 
433  void filter_mask(const bit_array & mask)
434  {
435  t_size n,count = get_size(), total = 0;
436 
437  n = total = mask.find(false,0,count);
438 
439  if (n<count) {
440  for(n=mask.find(true,n+1,count-n-1);n<count;n=mask.find(true,n+1,count-n-1))
441  ::pfc::move_t(m_buffer[total++],m_buffer[n]);
442 
443  m_buffer.set_size(total);
444  }
445  }
446 
447  void replace_item(t_size idx,const T& item)
448  {
449  PFC_ASSERT(idx>=0);
450  PFC_ASSERT(idx<get_size());
451  m_buffer[idx] = item;
452  }
453 
454  void sort()
455  {
457  ::pfc::sort(wrapper,get_size());
458  }
459 
460  template<typename t_compare>
461  void sort_t(t_compare p_compare)
462  {
464  ::pfc::sort(wrapper,get_size());
465  }
466 
467  template<typename t_compare>
468  void sort_stable_t(t_compare p_compare)
469  {
471  ::pfc::sort_stable(wrapper,get_size());
472  }
473  inline void reorder_partial(t_size p_base,const t_size * p_order,t_size p_count)
474  {
475  PFC_ASSERT(p_base+p_count<=get_size());
476  ::pfc::reorder_partial_t(m_buffer,p_base,p_order,p_count);
477  }
478 
479  template<typename t_compare>
480  t_size find_duplicates_sorted_t(t_compare p_compare,bit_array_var & p_out) const
481  {
482  return ::pfc::find_duplicates_sorted_t<list_impl_t<T,t_storage> const &,t_compare>(*this,get_size(),p_compare,p_out);
483  }
484 
485  template<typename t_compare,typename t_permutation>
486  t_size find_duplicates_sorted_permutation_t(t_compare p_compare,t_permutation p_permutation,bit_array_var & p_out)
487  {
488  return ::pfc::find_duplicates_sorted_permutation_t<list_impl_t<T,t_storage> const &,t_compare,t_permutation>(*this,get_size(),p_compare,p_permutation,p_out);
489  }
490 
491 
492  void move_from(t_self & other) {
493  remove_all();
494  m_buffer = std::move(other.m_buffer);
495  }
496 
497 private:
499  {
500  public:
501  explicit inline sort_callback_wrapper(typename t_base::sort_callback & p_callback) : m_callback(p_callback) {}
502  inline int operator()(const T& item1,const T& item2) const {return m_callback.compare(item1,item2);}
503  private:
505  };
506 public:
507  void sort(typename t_base::sort_callback & p_callback)
508  {
509  sort_t(sort_callback_wrapper(p_callback));
510  }
511 
512  void sort_stable(typename t_base::sort_callback & p_callback)
513  {
514  sort_stable_t(sort_callback_wrapper(p_callback));
515  }
516 
517  void remove_mask(const bit_array & mask) {filter_mask(bit_array_not(mask));}
518 
519  void remove_mask(const bool * mask) {remove_mask(bit_array_table(mask,get_size()));}
520  void filter_mask(const bool * mask) {filter_mask(bit_array_table(mask,get_size()));}
521 
522  t_size add_item(const T& item) {
523  return insert_item(item, ~0);
524  }
525 
526  template<typename t_in> t_size add_item(const t_in & item) {
527  return insert_item(item, ~0);
528  }
529 
530  void remove_all() {remove_mask(bit_array_true());}
531 
532  void remove_item(const T& item)
533  {
534  t_size n,max = get_size();
535  bit_array_bittable mask(max);
536  for(n=0;n<max;n++)
537  mask.set(n,get_item(n)==item);
538  remove_mask(mask);
539  }
540 
541  void swap_item_with(t_size p_index,T & p_item)
542  {
543  PFC_ASSERT(p_index < get_size());
544  swap_t(m_buffer[p_index],p_item);
545  }
546 
547  void swap_items(t_size p_index1,t_size p_index2)
548  {
549  PFC_ASSERT(p_index1 < get_size());
550  PFC_ASSERT(p_index2 < get_size());
551  swap_t(m_buffer[p_index1],m_buffer[p_index2]);
552  }
553 
554  inline static void g_swap(list_impl_t<T,t_storage> & p_item1,list_impl_t<T,t_storage> & p_item2)
555  {
556  swap_t(p_item1.m_buffer,p_item2.m_buffer);
557  }
558 
559  template<typename t_search>
560  t_size find_item(const t_search & p_item) const//returns index of first occurance, infinite if not found
561  {
562  t_size n,max = get_size();
563  for(n=0;n<max;n++)
564  if (m_buffer[n]==p_item) return n;
565  return ~0;
566  }
567 
568  template<typename t_search>
569  inline bool have_item(const t_search & p_item) const {return this->template find_item<t_search>(p_item)!=~0;}
570 
571  template<typename t_in> t_self & operator=(t_in const & source) {remove_all(); add_items(source); return *this;}
572  template<typename t_in> t_self & operator+=(t_in const & p_source) {add_item(p_source); return *this;}
573  template<typename t_in> t_self & operator|=(t_in const & p_source) {add_items(p_source); return *this;}
574 protected:
575  t_storage m_buffer;
576 };
577 
578 template<typename t_item, template<typename> class t_alloc = alloc_fast >
579 class list_t : public list_impl_t<t_item,array_t<t_item,t_alloc> > {
580 public:
582  template<typename t_in> t_self & operator=(t_in const & source) {this->remove_all(); this->add_items(source); return *this;}
583  template<typename t_in> t_self & operator+=(t_in const & p_source) {this->add_item(p_source); return *this;}
584  template<typename t_in> t_self & operator|=(t_in const & p_source) {this->add_items(p_source); return *this;}
585 };
586 
587 template<typename t_item, t_size p_fixed_count, template<typename> class t_alloc = alloc_fast >
588 class list_hybrid_t : public list_impl_t<t_item,array_hybrid_t<t_item,p_fixed_count,t_alloc> > {
589 public:
591  template<typename t_in> t_self & operator=(t_in const & source) {this->remove_all(); this->add_items(source); return *this;}
592  template<typename t_in> t_self & operator+=(t_in const & p_source) {this->add_item(p_source); return *this;}
593  template<typename t_in> t_self & operator|=(t_in const & p_source) {this->add_items(p_source); return *this;}
594 };
595 
596 template<typename T>
597 class ptr_list_const_cast_t : public list_base_const_t<const T *>
598 {
599 public:
600  inline ptr_list_const_cast_t(const list_base_const_t<T*> & p_param) : m_param(p_param) {}
601  t_size get_count() const {return m_param.get_count();}
602  void get_item_ex(const T * & p_out,t_size n) const {T* temp; m_param.get_item_ex(temp,n); p_out = temp;}
603 private:
605 
606 };
607 
608 
609 template<typename T,typename P>
611 {
612 public:
613  inline list_const_permutation_t(const list_base_const_t<T> & p_list,P p_permutation) : m_list(p_list), m_permutation(p_permutation) {}
614  t_size get_count() const {return m_list.get_count();}
615  void get_item_ex(T & p_out,t_size n) const {m_list.get_item_ex(p_out,m_permutation[n]);}
616 private:
619 };
620 
621 
622 template<class T>
624 {
625 public:
626  t_size get_count() const {return m_count;}
627  void get_item_ex(T & p_out,t_size n) const {m_base.get_item_ex(p_out,m_order[n]);}
628  list_permutation_t(const list_base_const_t<T> & p_base,const t_size * p_order,t_size p_count)
629  : m_base(p_base), m_order(p_order), m_count(p_count)
630  {
631  PFC_ASSERT(m_base.get_count() >= m_count);
632  }
633 private:
635  const t_size * m_order;
637 };
638 
639 template<typename item, template<typename> class alloc> class traits_t<list_t<item, alloc> > : public combine_traits<traits_t<alloc<item> >, traits_vtable> {};
640 
641 }
642 #endif //_PFC_LIST_H_
t_self & operator+=(t_in const &p_source)
Definition: list.h:583
void sort()
Definition: list.h:454
void remove_duplicates_t(t_compare p_compare)
Definition: list.h:257
t_filesize get_size(HANDLE p_handle)
void for_each(t_func p_func)
Definition: list.h:267
t_size find_item(const t_search &p_item) const
Definition: list.h:560
void sort(pfc::sort_callback &p_callback, t_size p_num)
Definition: sort.cpp:225
void get_item_ex(T &p_out, t_size n) const
Definition: list.h:117
T get_item(t_size n) const
Definition: list.h:358
ptr_list_const_array_t(A p_data, t_size p_count)
Definition: list.h:161
t_self & operator+=(t_in const &p_source)
Definition: list.h:592
t_size add_item(const T &item)
Definition: list.h:210
t_self & operator=(t_in const &source)
Definition: list.h:571
void sort_stable_remove_duplicates_t(t_compare p_compare)
Definition: list.h:248
void move_from(t_self &other)
Definition: list.h:492
const T & get_item_ref(t_size n) const
Definition: list.h:351
T operator[](t_size n) const
Definition: list.h:17
t_size get_size() const
Definition: list.h:366
virtual t_size find(bool val, t_size start, t_ssize count) const
Returns the first occurance of val between start and start+count (excluding start+count), or start+count if not found; count may be negative to search back rather than forward. Can be overridden by bit_array implementations for improved speed in specific cases.
Definition: bit_array.h:11
Generic variable bit_array implementation. Needs to be initialized with requested array size before ...
t_size insert_items(const t_in &source, t_size base)
Definition: list.h:406
unsigned insert_item(HWND p_listview, unsigned p_index, const char *p_name, LPARAM p_param)
t_self & operator=(t_in const &source)
Definition: list.h:591
t_base::sort_callback & m_callback
Definition: list.h:504
t_self & operator=(t_in const &source)
Definition: list.h:582
void sort_stable_get_permutation_t(t_compare p_compare, t_permutation const &p_permutation) const
Definition: list.h:60
int operator()(const T &item1, const T &item2) const
Definition: list.h:502
void get_items_mask(list_impl_t< T, t_storage > &out, const bit_array &mask)
Definition: list.h:426
bool have_item(const t_search &p_item) const
Definition: list.h:41
void add_items(const t_in &in)
Definition: list.h:424
void remove_mask(const bit_array &mask)
Definition: list.h:212
const list_base_const_t< from > & m_from
Definition: list.h:154
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
Definition: bit_array.h:6
t_size _insert_item_t(const t_in &item, t_size idx)
Definition: list.h:319
list_impl_t< T, t_storage > t_self
Definition: list.h:309
void get_item_ex(T &p_out, t_size n) const
Definition: list.h:96
int compare(t1 const &p1, t2 const &p2)
Definition: pathUtils.h:29
bit_array_table_t< bool > bit_array_table
int compare(const T &p_item1, const T &p_item2)
Definition: list.h:225
void prealloc(t_size count)
Definition: list.h:313
void remove_all_ex(t_releasefunc p_func)
Definition: list.h:287
list_base_t< T > t_self
Definition: list.h:183
const list_base_const_t< T > t_self_const
Definition: list.h:184
void set(t_size n, bool val)
t_size get_count() const
Definition: list.h:135
void filter_mask(const bit_array &mask)
Definition: list.h:433
void get_item_ex(T &p_out, t_size n) const
Definition: list.h:174
T & operator[](t_size n)
Definition: list.h:378
t_size get_count() const
Definition: list.h:626
void sort()
Definition: list.h:236
list_hybrid_t< t_item, p_fixed_count, t_alloc > t_self
Definition: list.h:590
void enumerate(t_callback &p_callback) const
Definition: list.h:65
const list_base_const_t< T * > & m_param
Definition: list.h:604
list_base_t< T > t_base
Definition: list.h:308
bool bsearch_permutation_t(t_size p_count, const t_container &p_container, t_compare p_compare, const t_param &p_param, const t_permutation &p_permutation, t_size &p_index)
Definition: bsearch.h:56
const T * m_data
Definition: list.h:176
list_permutation_t(const list_base_const_t< T > &p_base, const t_size *p_order, t_size p_count)
Definition: list.h:628
t_self & operator+=(t_in const &p_source)
Definition: list.h:293
t_size get_count() const
Definition: list.h:365
void reorder_partial_t(t_container &p_data, t_size p_base, const t_size *p_order, t_size p_count)
Definition: sort.h:49
const list_base_const_t< T > & m_list
Definition: list.h:618
t_size find_duplicates_sorted_t(t_compare p_compare, bit_array_var &p_out) const
Definition: list.h:480
void sort_stable(sort_callback &p_callback, t_size p_count)
Definition: sort.cpp:261
Negation of another array. Valid index range is the same as valid index range of the parameter array...
const T * get_ptr() const
Definition: list.h:375
void get_item_ex(T &p_out, t_size n) const
Definition: list.h:615
void sort_remove_duplicates_t(t_compare p_compare)
Definition: list.h:240
list_single_ref_t(const T &p_item, t_size p_count=1)
Definition: list.h:94
bool bsearch_t(t_compare p_compare, t_param const &p_param, t_size &p_index) const
Definition: list.h:45
t_size insert_items(const list_base_const_t< T > &source, t_size base)
Definition: list.h:402
sort_callback_impl_t(t_compare p_compare)
Definition: list.h:224
void move_t(T &p_item1, T &p_item2)
This is similar to plain p_item1 = p_item2; assignment, but optimized for the case where p_item2 cont...
Definition: primitives.h:298
T replace_item_ex(t_size p_index, const T &p_item)
Definition: list.h:216
void set_count(t_size p_count)
Definition: list.h:315
void filter_mask(const bool *mask)
Definition: list.h:520
t_size find_item(const t_search &p_item) const
Definition: list.h:32
t_size insert_items(const list_base_t< T > &source, t_size base)
Definition: list.h:403
void remove_mask(const bool *mask)
Definition: list.h:519
void remove_mask(const bit_array &mask)
Definition: list.h:517
list_base_const_t(const t_self &)
Definition: list.h:84
bool bsearch_permutation_t(t_compare p_compare, t_param const &p_param, const t_permutation &p_permutation, t_size &p_index) const
Definition: list.h:50
void get_item_ex(T *&p_out, t_size n) const
Definition: list.h:163
t_size _insert_items_v(const list_base_const_t< T > &source, t_size base)
Definition: list.h:385
list_const_cast_t(const list_base_const_t< from > &p_from)
Definition: list.h:145
void get_item_ex(to &p_out, t_size n) const
Definition: list.h:147
t_size insert_items_fromptr(const T *source, t_size num, t_size base)
Definition: list.h:206
const list_base_const_t< T > & m_base
Definition: list.h:634
t_size get_count() const
Definition: list.h:116
void sort_stable_t(t_compare p_compare)
Definition: list.h:468
t_size get_size() const
Definition: list.h:14
const T & operator[](t_size n) const
Definition: list.h:368
size_t t_size
Definition: int_types.h:48
t_self & operator|=(t_in const &p_source)
Definition: list.h:584
t_size add_item(const T &item)
Definition: list.h:522
virtual t_size get_count() const =0
t_size get_count() const
Definition: list.h:95
t_size get_count() const
Definition: list.h:162
list_impl_t(const t_self &p_source)
Definition: list.h:311
T remove_by_idx(t_size idx)
Definition: list.h:331
t_size get_count() const
Definition: list.h:614
void sort_stable_t(t_compare p_compare)
Definition: list.h:238
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:20
list_const_ptr_t(const T *p_data, t_size p_count)
Definition: list.h:172
list_const_permutation_t(const list_base_const_t< T > &p_list, P p_permutation)
Definition: list.h:613
void swap_item_with(t_size p_index, T &p_item)
Definition: list.h:541
Bit array interface class, variable version (you can both set and retrieve values). As with the constant version, valid index range depends on the context.
Definition: bit_array.h:40
void get_item_ex(T &p_out, t_size n) const
Definition: list.h:344
list_t< t_item, t_alloc > t_self
Definition: list.h:581
void remove_from_idx(t_size idx, t_size num)
Definition: list.h:380
const list_base_const_t< T > & m_list
Definition: list.h:113
list_partial_ref_t(const list_base_const_t< T > &p_list, t_size p_base, t_size p_count)
Definition: list.h:106
t_self & operator|=(t_in const &p_source)
Definition: list.h:294
t_self & operator|=(t_in const &p_source)
Definition: list.h:593
const T & m_item
Definition: list.h:98
T operator[](t_size n) const
Definition: list.h:218
void get_item_ex(const T *&p_out, t_size n) const
Definition: list.h:602
void remove_all()
Definition: list.h:530
list_base_t(const t_self &)
Definition: list.h:299
void reorder(const t_size *p_data)
Definition: list.h:201
void get_item_ex(typename t_array::t_item &out, t_size n) const
Definition: list.h:136
void truncate(t_size val)
Definition: list.h:214
t_size get_count() const
Definition: list.h:173
void get_item_ex(T &p_out, t_size n) const
Definition: list.h:627
void get_item_ex(T &p_out, t_size n) const
Definition: list.h:126
list_const_array_t(A p_data, t_size p_count)
Definition: list.h:124
t_size insert_item(const T &item, t_size idx)
Definition: list.h:327
t_size add_items_repeat(T item, t_size num)
Definition: list.h:205
static void sort_t(t_container &p_data, t_compare p_compare, t_size p_count)
Definition: sort.h:162
void set_size(t_size p_count)
Definition: list.h:316
void sort_t(t_compare p_compare)
Definition: list.h:237
void remove_item(const T &item)
Definition: list.h:532
void reorder_partial(t_size p_base, const t_size *p_order, t_size p_count)
Definition: list.h:473
t_size insert_item(const t_in &item, t_size idx)
Definition: list.h:323
void swap_items(t_size p_index1, t_size p_index2)
Definition: list.h:547
void remove_all()
Definition: list.h:213
t_size get_count() const
Definition: list.h:125
void remove_mask_ex(const bit_array &p_mask, t_releasefunc p_func)
Definition: list.h:281
const t_size * m_order
Definition: list.h:635
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
list_base_const_t< T > t_self
Definition: list.h:8
void sort_t(t_compare p_compare)
Definition: list.h:461
const t_array & m_data
Definition: list.h:138
t_size add_items(const list_base_const_t< T > &items)
Definition: list.h:209
t_storage m_buffer
Definition: list.h:575
bool operator!=(const t_self &item2) const
Definition: list.h:78
void sort(typename t_base::sort_callback &p_callback)
Definition: list.h:507
int compare(const T &p_item1, const T &p_item2)
Definition: list.h:233
t_size add_item(const t_in &item)
Definition: list.h:526
t_size get_count() const
Definition: list.h:601
static bool g_equals(const t_self &item1, const t_self &item2)
Definition: list.h:71
t_self & operator|=(t_in const &p_source)
Definition: list.h:573
void operator=(const t_self &)
Definition: list.h:300
t_size find_duplicates_sorted_permutation_t(t_compare p_compare, t_permutation const &p_permutation, bit_array_var &p_out)
Definition: list.h:26
void sort_get_permutation_t(t_compare p_compare, t_permutation const &p_permutation) const
Definition: list.h:55
t_size find_duplicates_sorted_t(t_compare p_compare, bit_array_var &p_out) const
Definition: list.h:20
bool operator==(const t_self &item2) const
Definition: list.h:77
virtual void get_item_ex(T &p_out, t_size n) const =0
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
list_const_array_ref_t(const t_array &data)
Definition: list.h:134
void replace_item(t_size idx, const T &item)
Definition: list.h:447
void operator=(const t_self &)
Definition: list.h:85
t_size add_items_fromptr(const T *source, t_size num)
Definition: list.h:207
void sort_stable(typename t_base::sort_callback &p_callback)
Definition: list.h:512
t_size insert_items_repeat(const T &item, t_size num, t_size base)
Definition: list.h:204
t_size find_duplicates_sorted_permutation_t(t_compare p_compare, t_permutation p_permutation, bit_array_var &p_out)
Definition: list.h:486
void for_each(t_func p_func, const bit_array &p_mask)
Definition: list.h:273
t_self & operator+=(t_in const &p_source)
Definition: list.h:572
static void sort_stable_t(t_container &p_data, t_compare p_compare, t_size p_count)
Definition: sort.h:169
t_size get_count() const
Definition: list.h:146
t_size insert_t(t_array &p_array, const T &p_item, t_size p_index)
Definition: primitives.h:500
bool have_item(const t_search &p_item) const
Definition: list.h:569
t_size insert_item(const T &item, t_size base)
Definition: list.h:203
sort_callback_wrapper(typename t_base::sort_callback &p_callback)
Definition: list.h:501
t_self & operator=(t_in const &source)
Definition: list.h:292
T get_item(t_size n) const
Definition: list.h:16
bool bsearch_t(t_size p_count, const t_container &p_container, t_compare p_compare, const t_param &p_param, t_size &p_index)
Definition: bsearch.h:48
T * get_ptr()
Definition: list.h:376
ptr_list_const_cast_t(const list_base_const_t< T * > &p_param)
Definition: list.h:600
static void g_swap(list_impl_t< T, t_storage > &p_item1, list_impl_t< T, t_storage > &p_item2)
Definition: list.h:554