foobar2000 SDK  2015-08-03
Public Member Functions | Protected Member Functions
pfc::bit_arrayabstract

#include <bit_array.h>

+ Inheritance diagram for pfc::bit_array:

Public Member Functions

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
 
virtual bool get (t_size n) const =0
 
bool operator[] (t_size n) const
 

Protected Member Functions

 bit_array ()
 
 ~bit_array ()
 

Detailed Description

Bit array interface class, constant version (you can only retrieve values).
Range of valid indexes depends on the context. When passing a bit_array as a parameter to some code, valid index range must be signaled independently.

Definition at line 6 of file bit_array.h.

Constructor & Destructor Documentation

pfc::bit_array::bit_array ( )
inlineprotected

Definition at line 34 of file bit_array.h.

34 {}
pfc::bit_array::~bit_array ( )
inlineprotected

Definition at line 35 of file bit_array.h.

35 {}

Member Function Documentation

t_size pfc::bit_array::calc_count ( bool  val,
t_size  start,
t_size  count,
t_size  count_max = ~0 
) const
inline

Definition at line 22 of file bit_array.h.

23  {
24  t_size found = 0;
25  t_size max = start+count;
26  t_size ptr;
27  for(ptr=find(val,start,count);found<count_max && ptr<max;ptr=find(val,ptr+1,max-ptr-1)) found++;
28  return found;
29  }
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
size_t t_size
Definition: int_types.h:48
virtual t_size pfc::bit_array::find ( bool  val,
t_size  start,
t_ssize  count 
) const
inlinevirtual

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.

Reimplemented in bit_array_one, bit_array_val, bit_array_false, bit_array_true, bit_array_not, pfc::bit_array_flatIndexList, and pfc::bit_array_var_impl.

Definition at line 11 of file bit_array.h.

12  {
13  t_ssize d, todo, ptr = start;
14  if (count==0) return start;
15  else if (count<0) {d = -1; todo = -count;}
16  else {d = 1; todo = count;}
17  while(todo>0 && get(ptr)!=val) {ptr+=d;todo--;}
18  return ptr;
19  }
pfc::sized_int_t< sizeof(size_t) >::t_signed t_ssize
Definition: int_types.h:49
t_size pfc::bit_array::find_first ( bool  val,
t_size  start,
t_size  max 
) const
inline

Definition at line 31 of file bit_array.h.

31 {return find(val,start,max-start);}
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
t_size pfc::bit_array::find_next ( bool  val,
t_size  previous,
t_size  max 
) const
inline

Definition at line 32 of file bit_array.h.

32 {return find(val,previous+1,max-(previous+1));}
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
virtual bool pfc::bit_array::get ( t_size  n) const
pure virtual
bool pfc::bit_array::operator[] ( t_size  n) const
inline

Definition at line 20 of file bit_array.h.

20 {return get(n);}

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