11 virtual t_size get_count()
const = 0;
12 virtual void get_item_ex(
T& p_out,
t_size n)
const = 0;
16 inline T get_item(
t_size n)
const {
T temp; get_item_ex(temp,n);
return std::move(temp);}
19 template<
typename t_compare>
22 return ::pfc::find_duplicates_sorted_t<list_base_const_t<T>
const &,t_compare>(*
this,get_count(),p_compare,p_out);
25 template<
typename t_compare,
typename t_permutation>
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);
31 template<
typename t_search>
34 t_size n,max = get_count();
36 if (get_item(n)==p_item)
return n;
40 template<
typename t_search>
41 inline bool have_item(
const t_search & p_item)
const {
return find_item<t_search>(p_item)!=~0;}
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 {
49 template<
typename t_compare,
typename t_param,
typename t_permutation>
54 template<
typename t_compare,
typename t_permutation>
56 ::pfc::sort_get_permutation_t<list_base_const_t<T>,t_compare,t_permutation>(*
this,p_compare,get_count(),p_permutation);
59 template<
typename t_compare,
typename t_permutation>
61 ::pfc::sort_stable_get_permutation_t<list_base_const_t<T>,t_compare,t_permutation>(*
this,p_compare,get_count(),p_permutation);
64 template<
typename t_callback>
66 for(
t_size n = 0, m = get_count(); n < m; ++n ) {
67 p_callback( (*
this)[n] );
71 static bool g_equals(
const t_self & item1,
const t_self & item2) {
73 if (count != item2.
get_count())
return false;
74 for(
t_size walk = 0; walk < count; ++walk)
if (item1[walk] != item2[walk])
return false;
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);}
107 : m_list(p_list), m_base(p_base), m_count(p_count)
109 PFC_ASSERT(m_base + m_count <= m_list.get_count());
120 template<
typename T,
typename A>
131 template<
typename t_array>
141 template<
typename to,
typename from>
150 m_from.get_item_ex(temp,n);
157 template<
typename T,
typename A>
189 virtual int compare(
const T& p_item1,
const T& p_item2) = 0;
192 virtual void filter_mask(
const bit_array & mask) = 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;
201 inline void reorder(
const t_size * p_data) {reorder_partial(0,p_data,this->get_count());}
220 template<
typename t_compare>
225 int compare(
const T& p_item1,
const T& p_item2) {
return m_compare(p_item1,p_item2);}
237 template<
typename t_compare>
void sort_t(t_compare p_compare) {
sort(sort_callback_impl_t<t_compare>(p_compare));}
242 sort_t<t_compare>(p_compare);
244 if (this->
template find_duplicates_sorted_t<t_compare>(p_compare,array) > 0)
250 sort_stable_t<t_compare>(p_compare);
252 if (this->
template find_duplicates_sorted_t<t_compare>(p_compare,array) > 0)
260 sort_get_permutation_t<t_compare,order_helper&>(p_compare,order);
262 if (this->
template find_duplicates_sorted_permutation_t<t_compare,order_helper const&>(p_compare,order,array) > 0)
266 template<
typename t_func>
268 t_size n,max=this->get_count();
269 for(n=0;n<max;n++) p_func(this->get_item(n));
272 template<
typename t_func>
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));
280 template<
typename t_releasefunc>
282 this->
template for_each<t_releasefunc>(p_func,p_mask);
286 template<
typename t_releasefunc>
288 this->
template for_each<t_releasefunc>(p_func);
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;}
304 template<
typename T,
typename t_storage>
318 template<
typename t_in>
322 template<
typename t_in>
324 return _insert_item_t(item, idx);
328 return _insert_item_t(item, idx);
333 T ret = m_buffer[idx];
335 t_size max = m_buffer.get_size();
336 for(n=idx+1;n<max;n++) {
339 m_buffer.set_size(max-1);
375 inline const T*
get_ptr()
const {
return m_buffer.get_ptr();}
387 if (base>count) base = count;
389 m_buffer.set_size(count+num);
391 for(
t_size n=count-1;(int)n>=(
int)base;n--) {
396 for(
t_size n=0;n<num;n++) {
405 template<
typename t_in>
408 if (base>count) base = count;
410 m_buffer.set_size(count+num);
412 for(
t_size n=count-1;(int)n>=(
int)base;n--) {
417 for(
t_size n=0;n<num;n++) {
418 m_buffer[n+base] = source[n];
423 template<
typename t_in>
429 for_each_bit_array(n,mask,
true,0,count)
437 n = total = mask.
find(
false,0,count);
440 for(n=mask.
find(
true,n+1,count-n-1);n<count;n=mask.
find(
true,n+1,count-n-1))
443 m_buffer.set_size(total);
451 m_buffer[idx] = item;
460 template<
typename t_compare>
467 template<
typename t_compare>
475 PFC_ASSERT(p_base+p_count<=
get_size());
479 template<
typename t_compare>
482 return ::pfc::find_duplicates_sorted_t<list_impl_t<T,t_storage>
const &,t_compare>(*
this,
get_size(),p_compare,p_out);
485 template<
typename t_compare,
typename t_permutation>
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);
494 m_buffer = std::move(other.m_buffer);
502 inline int operator()(
const T& item1,
const T& item2)
const {
return m_callback.compare(item1,item2);}
507 void sort(
typename t_base::sort_callback & p_callback)
509 sort_t(sort_callback_wrapper(p_callback));
537 mask.
set(n,get_item(n)==item);
544 swap_t(m_buffer[p_index],p_item);
551 swap_t(m_buffer[p_index1],m_buffer[p_index2]);
559 template<
typename t_search>
564 if (m_buffer[n]==p_item)
return n;
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;}
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;}
578 template<
typename t_item,
template<
typename>
class t_alloc =
alloc_fast >
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;}
587 template<
typename t_item, t_size p_fixed_count,
template<
typename>
class t_alloc =
alloc_fast >
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;}
609 template<
typename T,
typename P>
629 : m_base(p_base), m_order(p_order), m_count(p_count)
631 PFC_ASSERT(m_base.get_count() >= m_count);
639 template<
typename item,
template<
typename>
class alloc>
class traits_t<
list_t<item, alloc> > :
public combine_traits<traits_t<alloc<item> >, traits_vtable> {};
642 #endif //_PFC_LIST_H_
t_self & operator+=(t_in const &p_source)
void remove_duplicates_t(t_compare p_compare)
t_filesize get_size(HANDLE p_handle)
void for_each(t_func p_func)
t_size find_item(const t_search &p_item) const
void sort(pfc::sort_callback &p_callback, t_size p_num)
void get_item_ex(T &p_out, t_size n) const
T get_item(t_size n) const
ptr_list_const_array_t(A p_data, t_size p_count)
t_self & operator+=(t_in const &p_source)
t_size add_item(const T &item)
t_self & operator=(t_in const &source)
void sort_stable_remove_duplicates_t(t_compare p_compare)
void move_from(t_self &other)
const T & get_item_ref(t_size n) const
T operator[](t_size n) const
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.
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)
unsigned insert_item(HWND p_listview, unsigned p_index, const char *p_name, LPARAM p_param)
t_self & operator=(t_in const &source)
t_base::sort_callback & m_callback
t_self & operator=(t_in const &source)
void sort_stable_get_permutation_t(t_compare p_compare, t_permutation const &p_permutation) const
int operator()(const T &item1, const T &item2) const
void get_items_mask(list_impl_t< T, t_storage > &out, const bit_array &mask)
bool have_item(const t_search &p_item) const
void add_items(const t_in &in)
void remove_mask(const bit_array &mask)
const list_base_const_t< from > & m_from
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
t_size _insert_item_t(const t_in &item, t_size idx)
list_impl_t< T, t_storage > t_self
void get_item_ex(T &p_out, t_size n) const
int compare(t1 const &p1, t2 const &p2)
bit_array_table_t< bool > bit_array_table
int compare(const T &p_item1, const T &p_item2)
void prealloc(t_size count)
void remove_all_ex(t_releasefunc p_func)
const list_base_const_t< T > t_self_const
void set(t_size n, bool val)
void filter_mask(const bit_array &mask)
void get_item_ex(T &p_out, t_size n) const
list_hybrid_t< t_item, p_fixed_count, t_alloc > t_self
void enumerate(t_callback &p_callback) const
const list_base_const_t< T * > & m_param
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)
list_permutation_t(const list_base_const_t< T > &p_base, const t_size *p_order, t_size p_count)
t_self & operator+=(t_in const &p_source)
void reorder_partial_t(t_container &p_data, t_size p_base, const t_size *p_order, t_size p_count)
const list_base_const_t< T > & m_list
t_size find_duplicates_sorted_t(t_compare p_compare, bit_array_var &p_out) const
void sort_stable(sort_callback &p_callback, t_size p_count)
Negation of another array. Valid index range is the same as valid index range of the parameter array...
const T * get_ptr() const
void get_item_ex(T &p_out, t_size n) const
void sort_remove_duplicates_t(t_compare p_compare)
list_single_ref_t(const T &p_item, t_size p_count=1)
bool bsearch_t(t_compare p_compare, t_param const &p_param, t_size &p_index) const
t_size insert_items(const list_base_const_t< T > &source, t_size base)
sort_callback_impl_t(t_compare p_compare)
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...
T replace_item_ex(t_size p_index, const T &p_item)
void set_count(t_size p_count)
void filter_mask(const bool *mask)
t_size find_item(const t_search &p_item) const
t_size insert_items(const list_base_t< T > &source, t_size base)
void remove_mask(const bool *mask)
void remove_mask(const bit_array &mask)
list_base_const_t(const t_self &)
bool bsearch_permutation_t(t_compare p_compare, t_param const &p_param, const t_permutation &p_permutation, t_size &p_index) const
void get_item_ex(T *&p_out, t_size n) const
t_size _insert_items_v(const list_base_const_t< T > &source, t_size base)
list_const_cast_t(const list_base_const_t< from > &p_from)
void get_item_ex(to &p_out, t_size n) const
t_size insert_items_fromptr(const T *source, t_size num, t_size base)
const list_base_const_t< T > & m_base
void sort_stable_t(t_compare p_compare)
const T & operator[](t_size n) const
t_self & operator|=(t_in const &p_source)
t_size add_item(const T &item)
virtual t_size get_count() const =0
list_impl_t(const t_self &p_source)
T remove_by_idx(t_size idx)
void sort_stable_t(t_compare p_compare)
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
list_const_ptr_t(const T *p_data, t_size p_count)
list_const_permutation_t(const list_base_const_t< T > &p_list, P p_permutation)
void swap_item_with(t_size p_index, T &p_item)
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.
void get_item_ex(T &p_out, t_size n) const
list_t< t_item, t_alloc > t_self
void remove_from_idx(t_size idx, t_size num)
const list_base_const_t< T > & m_list
list_partial_ref_t(const list_base_const_t< T > &p_list, t_size p_base, t_size p_count)
t_self & operator|=(t_in const &p_source)
t_self & operator|=(t_in const &p_source)
T operator[](t_size n) const
void get_item_ex(const T *&p_out, t_size n) const
list_base_t(const t_self &)
void reorder(const t_size *p_data)
void get_item_ex(typename t_array::t_item &out, t_size n) const
void truncate(t_size val)
void get_item_ex(T &p_out, t_size n) const
void get_item_ex(T &p_out, t_size n) const
list_const_array_t(A p_data, t_size p_count)
t_size insert_item(const T &item, t_size idx)
t_size add_items_repeat(T item, t_size num)
static void sort_t(t_container &p_data, t_compare p_compare, t_size p_count)
void set_size(t_size p_count)
void sort_t(t_compare p_compare)
void remove_item(const T &item)
void reorder_partial(t_size p_base, const t_size *p_order, t_size p_count)
t_size insert_item(const t_in &item, t_size idx)
void swap_items(t_size p_index1, t_size p_index2)
void remove_mask_ex(const bit_array &p_mask, t_releasefunc p_func)
t_size array_size_t(const t_array &p_array)
list_base_const_t< T > t_self
void sort_t(t_compare p_compare)
t_size add_items(const list_base_const_t< T > &items)
bool operator!=(const t_self &item2) const
void sort(typename t_base::sort_callback &p_callback)
int compare(const T &p_item1, const T &p_item2)
t_size add_item(const t_in &item)
static bool g_equals(const t_self &item1, const t_self &item2)
t_self & operator|=(t_in const &p_source)
void operator=(const t_self &)
t_size find_duplicates_sorted_permutation_t(t_compare p_compare, t_permutation const &p_permutation, bit_array_var &p_out)
void sort_get_permutation_t(t_compare p_compare, t_permutation const &p_permutation) const
t_size find_duplicates_sorted_t(t_compare p_compare, bit_array_var &p_out) const
bool operator==(const t_self &item2) const
virtual void get_item_ex(T &p_out, t_size n) const =0
void swap_t(T &p_item1, T &p_item2)
list_const_array_ref_t(const t_array &data)
void replace_item(t_size idx, const T &item)
void operator=(const t_self &)
t_size add_items_fromptr(const T *source, t_size num)
void sort_stable(typename t_base::sort_callback &p_callback)
t_size insert_items_repeat(const T &item, t_size num, t_size base)
t_size find_duplicates_sorted_permutation_t(t_compare p_compare, t_permutation p_permutation, bit_array_var &p_out)
void for_each(t_func p_func, const bit_array &p_mask)
t_self & operator+=(t_in const &p_source)
static void sort_stable_t(t_container &p_data, t_compare p_compare, t_size p_count)
t_size insert_t(t_array &p_array, const T &p_item, t_size p_index)
bool have_item(const t_search &p_item) const
t_size insert_item(const T &item, t_size base)
sort_callback_wrapper(typename t_base::sort_callback &p_callback)
t_self & operator=(t_in const &source)
T get_item(t_size n) const
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)
ptr_list_const_cast_t(const list_base_const_t< T * > &p_param)
static void g_swap(list_impl_t< T, t_storage > &p_item1, list_impl_t< T, t_storage > &p_item2)