1 #ifndef _PFC_BIT_ARRAY_IMPL_H_ 2 #define _PFC_BIT_ARRAY_IMPL_H_ 12 : data(p_data), count(p_count), after(p_after)
18 if (n<count)
return !!data[n];
31 : data(p_data), count(p_count), after(p_after)
36 if (n<count)
return !!data[n];
41 if (n<count) data[n] = !!val;
58 bool rv = n>=begin && n<end;
93 bool v1 = a1.
get(n), v2 = a2.
get(n);
94 return (v1 && !v2) || (!v1 && v2);
107 {
return a1.
find(!val,start,count);}
116 {
return val ? start : start+
count;}
124 {
return val ? start+count : start;}
134 {
return val==p_val ? start : start+
count;}
142 virtual bool get(
t_size n)
const {
return n==val;}
146 if (count==0)
return start;
150 return (val>=start && val<start+count) ? val : start+
count;
152 return (val<=start && val>start+count) ? val : start+
count;
156 if (start == val)
return count>0 ? start+1 : start-1;
170 template<
typename t_array>
173 return !! (p_array[idx>>3] & (1<<(idx&7)));
176 template<
typename t_array>
179 unsigned char & dst = p_array[idx>>3];
180 unsigned char mask = 1<<(idx&7);
181 dst = val ? dst|mask : dst&~mask;
188 t_size old_bytes = g_estimate_size(m_count);
190 t_size bytes = g_estimate_size(m_count);
198 for(
size_t w = in.
find_first(
true, 0, inSize); w < inSize; w = in.
find_next(
true, w, inSize) ) {
216 rv = g_get(m_data,n);
230 return m_order[n] != n;
237 #define for_each_bit_array(var,mask,val,start,count) for(var = mask.find(val,start,count);var<start+count;var=mask.find(val,var+1,count-(var+1-start))) 240 #endif //_PFC_BIT_ARRAY_IMPL_H_ t_size find(bool p_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.
void resize(t_size p_count)
const t_item * get_ptr() const
t_size find_next(bool val, t_size previous, t_size max) const
bit_array_var_table_t(T *p_data, t_size p_count, bool p_after=false)
t_size find_first(bool val, t_size start, t_size max) const
static bool g_get(const t_array &p_array, t_size idx)
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 ...
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
bit_array_not(const bit_array &p_a1)
bit_array_table_t< bool > bit_array_table
bit_array_var_table_t< bool > bit_array_var_table
bit_array_order_changed(const t_size *p_order)
bit_array_one(t_size p_val)
bit_array_or(const bit_array &p_a1, const bit_array &p_a2)
Negation of another array. Valid index range is the same as valid index range of the parameter array...
bit_array_and(const bit_array &p_a1, const bit_array &p_a2)
static void g_set(t_array &p_array, t_size idx, bool val)
virtual bool get(t_size n) const =0
Combines two arrays using the AND logical operator. Valid index range is an intersection of valid in...
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.
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.
Combines two arrays using the XOR logical operator. Valid index range is an intersection of valid in...
void set_size(t_size p_size)
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.
void memset_null_t(T *p_buffer, t_size p_count)
bit_array_bittable(t_size p_count)
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.
virtual t_size find(bool p_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.
bit_array_xor(const bit_array &p_a1, const bit_array &p_a2)
pfc::sized_int_t< sizeof(size_t) >::t_signed t_ssize
Bit array that takes a permutation and signals indexes reordered by the permutation. Valid index range same as length of the permutation.
bit_array_bittable(const pfc::bit_array &in, size_t inSize)
bit_array_range(t_size first, t_size count, bool p_state=true)
bit_array_table_t(const T *p_data, t_size p_count, bool p_after=false)
pfc::array_t< t_uint8 > m_data
static t_size g_estimate_size(t_size p_count)
Combines two arrays using the OR logical operator. Valid index range is an intersection of valid ind...