foobar2000 SDK  2015-08-03
Public Member Functions | Private Attributes
pfc::bit_array_var_impl

#include <bit_array_impl_part2.h>

+ Inheritance diagram for pfc::bit_array_var_impl:

Public Member Functions

 bit_array_var_impl ()
 
 bit_array_var_impl (const bit_array &source, size_t sourceCount)
 
void clear ()
 
t_size find (bool val, t_size start, t_ssize count) const
 
bool get (t_size n) const
 
t_size get_true_count () const
 
void set (t_size n, bool val)
 
void set (t_size n)
 
void unset (t_size n)
 
- 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
 
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
 

Private Attributes

avltree_t< t_sizem_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.
Not very efficient to handle lots of items set to true but offers fast searches for true values and accepts arbitrary indexes, contrary to bit_array_bittable. Note that searches for false values are relatively inefficient.

Definition at line 4 of file bit_array_impl_part2.h.

Constructor & Destructor Documentation

pfc::bit_array_var_impl::bit_array_var_impl ( )
inline

Definition at line 6 of file bit_array_impl_part2.h.

6 {}
pfc::bit_array_var_impl::bit_array_var_impl ( const bit_array source,
size_t  sourceCount 
)

Definition at line 4 of file bit_array.cpp.

4  {
5  for(size_t w = source.find_first( true, 0, sourceCount); w < sourceCount; w = source.find_next( true, w, sourceCount ) ) {
6  set(w, true);
7  }
8  }
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

Member Function Documentation

void pfc::bit_array_var_impl::clear ( )
inline

Definition at line 14 of file bit_array_impl_part2.h.

14 {m_data.remove_all();}
avltree_t< t_size > m_data
void remove_all()
Definition: avltree.h:435
t_size pfc::bit_array_var_impl::find ( bool  val,
t_size  start,
t_ssize  count 
) const
virtual

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 from pfc::bit_array.

Definition at line 13 of file bit_array.cpp.

13  {
14  if (!val) {
15  return bit_array::find(false, start, count); //optimizeme.
16  } else if (count > 0) {
17  const t_size * v = m_data.find_nearest_item<true, true>(start);
18  if (v == NULL || *v > start+count) return start + count;
19  return *v;
20  } else if (count < 0) {
21  const t_size * v = m_data.find_nearest_item<true, false>(start);
22  if (v == NULL || *v < start+count) return start + count;
23  return *v;
24  } else return start;
25  }
const t_storage * find_nearest_item(const t_search &p_search) const
Definition: avltree.h:371
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
avltree_t< t_size > m_data
bool pfc::bit_array_var_impl::get ( t_size  n) const
virtual

Implements pfc::bit_array.

Definition at line 10 of file bit_array.cpp.

10  {
11  return m_data.have_item(n);
12  }
bool have_item(const t_param &p_item) const
Same as contains().
Definition: avltree.h:433
avltree_t< t_size > m_data
t_size pfc::bit_array_var_impl::get_true_count ( ) const
inline

Definition at line 13 of file bit_array_impl_part2.h.

13 {return m_data.get_count();}
t_size get_count() const
Definition: avltree.h:453
avltree_t< t_size > m_data
void pfc::bit_array_var_impl::set ( t_size  n,
bool  val 
)
virtual

Implements pfc::bit_array_var.

Definition at line 27 of file bit_array.cpp.

27  {
28  if (val) m_data += n;
29  else m_data -= n;
30  }
avltree_t< t_size > m_data
void pfc::bit_array_var_impl::set ( t_size  n)
inline

Definition at line 11 of file bit_array_impl_part2.h.

11 {m_data += n;}
avltree_t< t_size > m_data
void pfc::bit_array_var_impl::unset ( t_size  n)
inline

Definition at line 12 of file bit_array_impl_part2.h.

12 {m_data -= n;}
avltree_t< t_size > m_data

Field Documentation

avltree_t<t_size> pfc::bit_array_var_impl::m_data
private

Definition at line 16 of file bit_array_impl_part2.h.


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