foobar2000 SDK  2015-08-03
Public Member Functions | Static Public Member Functions | Private Attributes
bit_array_bittable

#include <bit_array_impl.h>

+ Inheritance diagram for bit_array_bittable:

Public Member Functions

 bit_array_bittable (t_size p_count)
 
 bit_array_bittable (const pfc::bit_array &in, size_t inSize)
 
 bit_array_bittable ()
 
bool get (t_size n) const
 
void resize (t_size p_count)
 
void set (t_size n, bool val)
 
- Public Member Functions inherited from pfc::bit_array
t_size calc_count (bool val, t_size start, t_size count, t_size count_max=~0) const
 
virtual t_size find (bool val, t_size start, t_ssize count) const
 
t_size find_first (bool val, t_size start, t_size max) const
 
t_size find_next (bool val, t_size previous, t_size max) const
 
bool operator[] (t_size n) const
 

Static Public Member Functions

static t_size g_estimate_size (t_size p_count)
 
template<typename t_array >
static bool g_get (const t_array &p_array, t_size idx)
 
template<typename t_array >
static void g_set (t_array &p_array, t_size idx, bool val)
 

Private Attributes

t_size m_count
 
pfc::array_t< t_uint8m_data
 

Additional Inherited Members

- Protected Member Functions inherited from pfc::bit_array_var
 bit_array_var ()
 
 ~bit_array_var ()
 
- Protected Member Functions inherited from pfc::bit_array
 bit_array ()
 
 ~bit_array ()
 

Detailed Description

Generic variable bit_array implementation.
Needs to be initialized with requested array size before use.

Definition at line 164 of file bit_array_impl.h.

Constructor & Destructor Documentation

bit_array_bittable::bit_array_bittable ( t_size  p_count)
inline

Definition at line 195 of file bit_array_impl.h.

195 : m_count(0) {resize(p_count);}
void resize(t_size p_count)
bit_array_bittable::bit_array_bittable ( const pfc::bit_array in,
size_t  inSize 
)
inline

Definition at line 196 of file bit_array_impl.h.

196  : m_count() {
197  resize(inSize);
198  for(size_t w = in.find_first(true, 0, inSize); w < inSize; w = in.find_next(true, w, inSize) ) {
199  set( w, true );
200  }
201  }
void resize(t_size p_count)
t_size find_next(bool val, t_size previous, t_size max) const
Definition: bit_array.h:32
t_size find_first(bool val, t_size start, t_size max) const
Definition: bit_array.h:31
bit_array_bittable::bit_array_bittable ( )
inline

Definition at line 202 of file bit_array_impl.h.

202 : m_count() {}

Member Function Documentation

static t_size bit_array_bittable::g_estimate_size ( t_size  p_count)
inlinestatic

Definition at line 184 of file bit_array_impl.h.

184 {return (p_count+7)>>3;}
template<typename t_array >
static bool bit_array_bittable::g_get ( const t_array &  p_array,
t_size  idx 
)
inlinestatic

Definition at line 171 of file bit_array_impl.h.

172  {
173  return !! (p_array[idx>>3] & (1<<(idx&7)));
174  }
template<typename t_array >
static void bit_array_bittable::g_set ( t_array &  p_array,
t_size  idx,
bool  val 
)
inlinestatic

Definition at line 177 of file bit_array_impl.h.

178  {
179  unsigned char & dst = p_array[idx>>3];
180  unsigned char mask = 1<<(idx&7);
181  dst = val ? dst|mask : dst&~mask;
182  }
bool bit_array_bittable::get ( t_size  n) const
inlinevirtual

Implements pfc::bit_array.

Definition at line 212 of file bit_array_impl.h.

213  {
214  bool rv = false;
215  if (n<m_count) {
216  rv = g_get(m_data,n);
217  }
218  return rv;
219  }
static bool g_get(const t_array &p_array, t_size idx)
pfc::array_t< t_uint8 > m_data
void bit_array_bittable::resize ( t_size  p_count)
inline

Definition at line 186 of file bit_array_impl.h.

187  {
188  t_size old_bytes = g_estimate_size(m_count);
189  m_count = p_count;
190  t_size bytes = g_estimate_size(m_count);
191  m_data.set_size(bytes);
192  if (bytes > old_bytes) pfc::memset_null_t(m_data.get_ptr()+old_bytes,bytes-old_bytes);
193  }
const t_item * get_ptr() const
Definition: array.h:213
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
void memset_null_t(T *p_buffer, t_size p_count)
Definition: primitives.h:638
pfc::array_t< t_uint8 > m_data
static t_size g_estimate_size(t_size p_count)
void bit_array_bittable::set ( t_size  n,
bool  val 
)
inlinevirtual

Implements pfc::bit_array_var.

Definition at line 204 of file bit_array_impl.h.

205  {
206  if (n<m_count)
207  {
208  g_set(m_data,n,val);
209  }
210  }
static void g_set(t_array &p_array, t_size idx, bool val)
pfc::array_t< t_uint8 > m_data

Field Documentation

t_size bit_array_bittable::m_count
private

Definition at line 167 of file bit_array_impl.h.

pfc::array_t<t_uint8> bit_array_bittable::m_data
private

Definition at line 166 of file bit_array_impl.h.


The documentation for this class was generated from the following file: