ReactOS  0.4.15-dev-2526-g0fb3c1e
_Base_bitset< _Nw > Struct Template Reference

#include <_bitset.h>

Public Types

typedef unsigned long _WordT
 

Public Member Functions

 _Base_bitset ()
 
 _Base_bitset (unsigned long __val)
 
_WordT_M_getword (size_t __pos)
 
_WordT _M_getword (size_t __pos) const
 
_WordT_M_hiword ()
 
_WordT _M_hiword () const
 
void _M_do_and (const _Base_bitset< _Nw > &__x)
 
void _M_do_or (const _Base_bitset< _Nw > &__x)
 
void _M_do_xor (const _Base_bitset< _Nw > &__x)
 
void _M_do_left_shift (size_t __shift)
 
void _M_do_right_shift (size_t __shift)
 
void _M_do_flip ()
 
void _M_do_set ()
 
void _M_do_reset ()
 
bool _M_is_equal (const _Base_bitset< _Nw > &__x) const
 
bool _M_is_any () const
 
size_t _M_do_count () const
 
unsigned long _M_do_to_ulong () const
 
size_t _M_do_find_first (size_t __not_found) const
 
size_t _M_do_find_next (size_t __prev, size_t __not_found) const
 

Static Public Member Functions

static size_t _STLP_CALL _S_whichword (size_t __pos)
 
static size_t _STLP_CALL _S_whichbyte (size_t __pos)
 
static size_t _STLP_CALL _S_whichbit (size_t __pos)
 
static _WordT _STLP_CALL _S_maskbit (size_t __pos)
 

Public Attributes

_WordT _M_w [_Nw]
 

Detailed Description

template<size_t _Nw>
struct _Base_bitset< _Nw >

Definition at line 107 of file _bitset.h.

Member Typedef Documentation

◆ _WordT

template<size_t _Nw>
typedef unsigned long _Base_bitset< _Nw >::_WordT

Definition at line 108 of file _bitset.h.

Constructor & Destructor Documentation

◆ _Base_bitset() [1/2]

template<size_t _Nw>
_Base_bitset< _Nw >::_Base_bitset ( )
inline

Definition at line 112 of file _bitset.h.

112 { _M_do_reset(); }
void _M_do_reset()
Definition: _bitset.h:172

◆ _Base_bitset() [2/2]

template<size_t _Nw>
_Base_bitset< _Nw >::_Base_bitset ( unsigned long  __val)
inline

Definition at line 114 of file _bitset.h.

114  {
115  _M_do_reset();
116  _M_w[0] = __val;
117  }
void _M_do_reset()
Definition: _bitset.h:172
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
_WordT _M_w[_Nw]
Definition: _bitset.h:110

Member Function Documentation

◆ _M_do_and()

template<size_t _Nw>
void _Base_bitset< _Nw >::_M_do_and ( const _Base_bitset< _Nw > &  __x)
inline

Definition at line 138 of file _bitset.h.

138  {
139  for ( size_t __i = 0; __i < _Nw; __i++ ) {
140  _M_w[__i] &= __x._M_w[__i];
141  }
142  }
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_count()

template<size_t _Nw>
size_t _Base_bitset< _Nw >::_M_do_count ( ) const
inline

Definition at line 190 of file _bitset.h.

190  {
191  const unsigned char* __byte_ptr = (const unsigned char*)_M_w;
192  const unsigned char* __end_ptr = (const unsigned char*)(_M_w+_Nw);
193 
194  return _Bs_G::_S_count(__byte_ptr, __end_ptr);
195  }
static size_t _S_count(const unsigned char *__beg, const unsigned char *__end)
Definition: bitset.cpp:30
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_find_first()

template<size_t _Nw>
size_t _Base_bitset< _Nw >::_M_do_find_first ( size_t  __not_found) const

Definition at line 88 of file _bitset.c.

88  {
89  for ( size_t __i = 0; __i < _Nw; __i++ ) {
90  _WordT __thisword = _M_w[__i];
91  if ( __thisword != __STATIC_CAST(_WordT,0) ) {
92  // find byte within word
93  for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {
94  unsigned char __this_byte
95  = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
96  if ( __this_byte )
97  return __i*__BITS_PER_WORD + __j*CHAR_BIT +
98  _Bs_G::_S_first_one(__this_byte);
99 
100  __thisword >>= CHAR_BIT;
101  }
102  }
103  }
104  // not found, so return an indication of failure.
105  return __not_found;
106 }
#define __BITS_PER_WORD
Definition: _bitset.c:26
static unsigned char _S_first_one(unsigned char __x)
Definition: bitset.cpp:95
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
#define CHAR_BIT
Definition: urlcache.c:62
unsigned long _WordT
Definition: _bitset.h:108
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_find_next()

template<size_t _Nw>
size_t _Base_bitset< _Nw >::_M_do_find_next ( size_t  __prev,
size_t  __not_found 
) const

Definition at line 110 of file _bitset.c.

111  {
112  // make bound inclusive
113  ++__prev;
114 
115  // check out of bounds
116  if ( __prev >= _Nw * __BITS_PER_WORD )
117  return __not_found;
118 
119  // search first word
120  size_t __i = _S_whichword(__prev);
121  _WordT __thisword = _M_w[__i];
122 
123  // mask off bits below bound
124  __thisword &= (~__STATIC_CAST(_WordT,0)) << _S_whichbit(__prev);
125 
126  if ( __thisword != __STATIC_CAST(_WordT,0) ) {
127  // find byte within word
128  // get first byte into place
129  __thisword >>= _S_whichbyte(__prev) * CHAR_BIT;
130  for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); ++__j ) {
131  unsigned char __this_byte
132  = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
133  if ( __this_byte )
134  return __i*__BITS_PER_WORD + __j*CHAR_BIT +
135  _Bs_G::_S_first_one(__this_byte);
136 
137  __thisword >>= CHAR_BIT;
138  }
139  }
140 
141  // check subsequent words
142  ++__i;
143  for ( ; __i < _Nw; ++__i ) {
144  /* _WordT */ __thisword = _M_w[__i];
145  if ( __thisword != __STATIC_CAST(_WordT,0) ) {
146  // find byte within word
147  for ( size_t __j = 0; __j < sizeof(_WordT); ++__j ) {
148  unsigned char __this_byte
149  = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
150  if ( __this_byte )
151  return __i*__BITS_PER_WORD + __j*CHAR_BIT +
152  _Bs_G::_S_first_one(__this_byte);
153 
154  __thisword >>= CHAR_BIT;
155  }
156  }
157  }
158 
159  // not found, so return an indication of failure.
160  return __not_found;
161 } // end _M_do_find_next
static size_t _STLP_CALL _S_whichword(size_t __pos)
Definition: _bitset.h:119
#define __BITS_PER_WORD
Definition: _bitset.c:26
static unsigned char _S_first_one(unsigned char __x)
Definition: bitset.cpp:95
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
#define CHAR_BIT
Definition: urlcache.c:62
static size_t _STLP_CALL _S_whichbyte(size_t __pos)
Definition: _bitset.h:122
static size_t _STLP_CALL _S_whichbit(size_t __pos)
Definition: _bitset.h:125
unsigned long _WordT
Definition: _bitset.h:108
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_flip()

template<size_t _Nw>
void _Base_bitset< _Nw >::_M_do_flip ( )
inline

Definition at line 160 of file _bitset.h.

160  {
161  for ( size_t __i = 0; __i < _Nw; __i++ ) {
162  _M_w[__i] = ~_M_w[__i];
163  }
164  }
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_left_shift()

template<size_t _Nw>
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE void _Base_bitset< _Nw >::_M_do_left_shift ( size_t  __shift)

Definition at line 35 of file _bitset.c.

35  {
36  if (__shift != 0) {
37  const size_t __wshift = __shift / __BITS_PER_WORD;
38  const size_t __offset = __shift % __BITS_PER_WORD;
39 
40  if (__offset == 0)
41  for (size_t __n = _Nw - 1; __n >= __wshift; --__n)
42  _M_w[__n] = _M_w[__n - __wshift];
43 
44  else {
45  const size_t __sub_offset = __BITS_PER_WORD - __offset;
46  for (size_t __n = _Nw - 1; __n > __wshift; --__n)
47  _M_w[__n] = (_M_w[__n - __wshift] << __offset) |
48  (_M_w[__n - __wshift - 1] >> __sub_offset);
49  _M_w[__wshift] = _M_w[0] << __offset;
50  }
51 
52  fill(_M_w + 0, _M_w + __wshift, __STATIC_CAST(_WordT,0));
53  }
54 }
return __n
Definition: _algo.h:75
#define __BITS_PER_WORD
Definition: _bitset.c:26
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
unsigned long _WordT
Definition: _bitset.h:108
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_or()

template<size_t _Nw>
void _Base_bitset< _Nw >::_M_do_or ( const _Base_bitset< _Nw > &  __x)
inline

Definition at line 144 of file _bitset.h.

144  {
145  for ( size_t __i = 0; __i < _Nw; __i++ ) {
146  _M_w[__i] |= __x._M_w[__i];
147  }
148  }
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_reset()

template<size_t _Nw>
void _Base_bitset< _Nw >::_M_do_reset ( )
inline

Definition at line 172 of file _bitset.h.

172 { memset(_M_w, 0, _Nw * sizeof(_WordT)); }
unsigned long _WordT
Definition: _bitset.h:108
#define memset(x, y, z)
Definition: compat.h:39
_WordT _M_w[_Nw]
Definition: _bitset.h:110

Referenced by _Base_bitset< _Nw >::_Base_bitset().

◆ _M_do_right_shift()

template<size_t _Nw>
void _Base_bitset< _Nw >::_M_do_right_shift ( size_t  __shift)

Definition at line 57 of file _bitset.c.

57  {
58  if (__shift != 0) {
59  const size_t __wshift = __shift / __BITS_PER_WORD;
60  const size_t __offset = __shift % __BITS_PER_WORD;
61  const size_t __limit = _Nw - __wshift - 1;
62 
63  if (__offset == 0)
64  for (size_t __n = 0; __n <= __limit; ++__n)
65  _M_w[__n] = _M_w[__n + __wshift];
66 
67  else {
68  const size_t __sub_offset = __BITS_PER_WORD - __offset;
69  for (size_t __n = 0; __n < __limit; ++__n)
70  _M_w[__n] = (_M_w[__n + __wshift] >> __offset) |
71  (_M_w[__n + __wshift + 1] << __sub_offset);
72  _M_w[__limit] = _M_w[_Nw-1] >> __offset;
73  }
74 
75  fill(_M_w + __limit + 1, _M_w + _Nw, __STATIC_CAST(_WordT,0));
76  }
77 }
return __n
Definition: _algo.h:75
#define __BITS_PER_WORD
Definition: _bitset.c:26
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
unsigned long _WordT
Definition: _bitset.h:108
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_set()

template<size_t _Nw>
void _Base_bitset< _Nw >::_M_do_set ( )
inline

Definition at line 166 of file _bitset.h.

166  {
167  for ( size_t __i = 0; __i < _Nw; __i++ ) {
168  _M_w[__i] = ~__STATIC_CAST(_WordT,0);
169  }
170  }
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
unsigned long _WordT
Definition: _bitset.h:108
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_to_ulong()

template<size_t _Nw>
unsigned long _Base_bitset< _Nw >::_M_do_to_ulong ( ) const

Definition at line 80 of file _bitset.c.

80  {
81  for (size_t __i = 1; __i < _Nw; ++__i)
82  if (_M_w[__i])
84  return _M_w[0];
85 } // End _M_do_to_ulong
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_overflow_error(const char *__msg)
Definition: _range_errors.c:78
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_do_xor()

template<size_t _Nw>
void _Base_bitset< _Nw >::_M_do_xor ( const _Base_bitset< _Nw > &  __x)
inline

Definition at line 150 of file _bitset.h.

150  {
151  for ( size_t __i = 0; __i < _Nw; __i++ ) {
152  _M_w[__i] ^= __x._M_w[__i];
153  }
154  }
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_getword() [1/2]

template<size_t _Nw>
_WordT& _Base_bitset< _Nw >::_M_getword ( size_t  __pos)
inline

Definition at line 132 of file _bitset.h.

132 { return _M_w[_S_whichword(__pos)]; }
static size_t _STLP_CALL _S_whichword(size_t __pos)
Definition: _bitset.h:119
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_getword() [2/2]

template<size_t _Nw>
_WordT _Base_bitset< _Nw >::_M_getword ( size_t  __pos) const
inline

Definition at line 133 of file _bitset.h.

133 { return _M_w[_S_whichword(__pos)]; }
static size_t _STLP_CALL _S_whichword(size_t __pos)
Definition: _bitset.h:119
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_hiword() [1/2]

template<size_t _Nw>
_WordT& _Base_bitset< _Nw >::_M_hiword ( )
inline

Definition at line 135 of file _bitset.h.

135 { return _M_w[_Nw - 1]; }
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_hiword() [2/2]

template<size_t _Nw>
_WordT _Base_bitset< _Nw >::_M_hiword ( ) const
inline

Definition at line 136 of file _bitset.h.

136 { return _M_w[_Nw - 1]; }
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_is_any()

template<size_t _Nw>
bool _Base_bitset< _Nw >::_M_is_any ( ) const
inline

Definition at line 182 of file _bitset.h.

182  {
183  for ( size_t __i = 0; __i < _Nw ; __i++ ) {
184  if ( _M_w[__i] != __STATIC_CAST(_WordT,0) )
185  return true;
186  }
187  return false;
188  }
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
unsigned long _WordT
Definition: _bitset.h:108
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _M_is_equal()

template<size_t _Nw>
bool _Base_bitset< _Nw >::_M_is_equal ( const _Base_bitset< _Nw > &  __x) const
inline

Definition at line 174 of file _bitset.h.

174  {
175  for (size_t __i = 0; __i < _Nw; ++__i) {
176  if (_M_w[__i] != __x._M_w[__i])
177  return false;
178  }
179  return true;
180  }
_WordT _M_w[_Nw]
Definition: _bitset.h:110

◆ _S_maskbit()

template<size_t _Nw>
static _WordT _STLP_CALL _Base_bitset< _Nw >::_S_maskbit ( size_t  __pos)
inlinestatic

Definition at line 128 of file _bitset.h.

128  {
129  return __STATIC_CAST(_WordT,1) << _S_whichbit(__pos);
130  }
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
static size_t _STLP_CALL _S_whichbit(size_t __pos)
Definition: _bitset.h:125
unsigned long _WordT
Definition: _bitset.h:108

Referenced by bitset< _Nb >::_Unchecked_set().

◆ _S_whichbit()

template<size_t _Nw>
static size_t _STLP_CALL _Base_bitset< _Nw >::_S_whichbit ( size_t  __pos)
inlinestatic

Definition at line 125 of file _bitset.h.

125  {
126  return __pos % __BITS_PER_WORD;
127  }
#define __BITS_PER_WORD
Definition: _bitset.h:62

Referenced by _Base_bitset< 1UL >::_M_do_find_next(), _Base_bitset< _Nw >::_S_maskbit(), and _Base_bitset< 1UL >::_S_maskbit().

◆ _S_whichbyte()

template<size_t _Nw>
static size_t _STLP_CALL _Base_bitset< _Nw >::_S_whichbyte ( size_t  __pos)
inlinestatic

Definition at line 122 of file _bitset.h.

122  {
123  return (__pos % __BITS_PER_WORD) / CHAR_BIT;
124  }
#define CHAR_BIT
Definition: urlcache.c:62
#define __BITS_PER_WORD
Definition: _bitset.h:62

Referenced by _Base_bitset< 1UL >::_M_do_find_next().

◆ _S_whichword()

template<size_t _Nw>
static size_t _STLP_CALL _Base_bitset< _Nw >::_S_whichword ( size_t  __pos)
inlinestatic

Definition at line 119 of file _bitset.h.

119  {
120  return __pos / __BITS_PER_WORD;
121  }
#define __BITS_PER_WORD
Definition: _bitset.h:62

Referenced by _Base_bitset< _Nw >::_M_getword().

Member Data Documentation

◆ _M_w


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