ReactOS  0.4.15-dev-2153-g62b4c61
bitset< _Nb > Class Template Reference

#include <_bitset.h>

Inheritance diagram for bitset< _Nb >:
Collaboration diagram for bitset< _Nb >:

Classes

struct  reference
 

Public Types

enum  { _Words = __BITSET_WORDS(_Nb) }
 
typedef unsigned long _WordT
 

Public Member Functions

 bitset ()
 
 bitset (unsigned long __val)
 
 bitset (const string &__s, size_t __pos=0, size_t __n=(size_t) -1)
 
bitset< _Nb > & operator&= (const bitset< _Nb > &__rhs)
 
bitset< _Nb > & operator|= (const bitset< _Nb > &__rhs)
 
bitset< _Nb > & operator^= (const bitset< _Nb > &__rhs)
 
bitset< _Nb > & operator<<= (size_t __pos)
 
bitset< _Nb > & operator>>= (size_t __pos)
 
bitset< _Nb > & _Unchecked_set (size_t __pos)
 
bitset< _Nb > & _Unchecked_set (size_t __pos, int __val)
 
bitset< _Nb > & _Unchecked_reset (size_t __pos)
 
bitset< _Nb > & _Unchecked_flip (size_t __pos)
 
bool _Unchecked_test (size_t __pos) const
 
bitset< _Nb > & set ()
 
bitset< _Nb > & set (size_t __pos)
 
bitset< _Nb > & set (size_t __pos, int __val)
 
bitset< _Nb > & reset ()
 
bitset< _Nb > & reset (size_t __pos)
 
bitset< _Nb > & flip ()
 
bitset< _Nb > & flip (size_t __pos)
 
bitset< _Nb > operator~ () const
 
reference operator[] (size_t __pos)
 
bool operator[] (size_t __pos) const
 
unsigned long to_ulong () const
 
string to_string () const
 
size_t count () const
 
size_t size () const
 
bool operator== (const bitset< _Nb > &__rhs) const
 
bool operator!= (const bitset< _Nb > &__rhs) const
 
bool test (size_t __pos) const
 
bool any () const
 
bool none () const
 
bitset< _Nb > operator<< (size_t __pos) const
 
bitset< _Nb > operator>> (size_t __pos) const
 
size_t _Find_first () const
 
size_t _Find_next (size_t __prev) const
 
void _M_copy_from_string (const string &__s, size_t __pos, size_t __n)
 
void _M_copy_to_string (string &__s) const
 
void _M_copy_to_string (wstring &__s) const
 

Private Types

typedef _STLP_PRIV _Base_bitset< _Words_Base
 

Private Member Functions

void _M_do_sanitize ()
 

Friends

struct reference
 

Detailed Description

template<size_t _Nb>
class bitset< _Nb >

Definition at line 347 of file _bitset.h.

Member Typedef Documentation

◆ _Base

template<size_t _Nb>
typedef _STLP_PRIV _Base_bitset< _Words > bitset< _Nb >::_Base
private

Definition at line 352 of file _bitset.h.

◆ _WordT

template<size_t _Nb>
typedef unsigned long bitset< _Nb >::_WordT

Definition at line 358 of file _bitset.h.

Member Enumeration Documentation

◆ anonymous enum

template<size_t _Nb>
anonymous enum
Enumerator
_Words 

Definition at line 349 of file _bitset.h.

349 { _Words = __BITSET_WORDS(_Nb) } ;
#define __BITSET_WORDS(__n)
Definition: _bitset.h:63

Constructor & Destructor Documentation

◆ bitset() [1/3]

template<size_t _Nb>
bitset< _Nb >::bitset ( )
inline

Definition at line 415 of file _bitset.h.

415 {}

◆ bitset() [2/3]

template<size_t _Nb>
bitset< _Nb >::bitset ( unsigned long  __val)
inline

Definition at line 417 of file _bitset.h.

void _M_do_sanitize()
Definition: _bitset.h:354
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
#define _STLP_PRIV
Definition: _dm.h:70

◆ bitset() [3/3]

template<size_t _Nb>
bitset< _Nb >::bitset ( const string __s,
size_t  __pos = 0,
size_t  __n = (size_t)-1 
)
inlineexplicit

Definition at line 439 of file _bitset.h.

443  if (__pos > __s.size())
444  __stl_throw_out_of_range("bitset");
445  _M_copy_from_string(__s, __pos, __n);
446  }
return __n
Definition: _algo.h:75
size_type size() const
Definition: _string.h:400
#define _STLP_PRIV
Definition: _dm.h:70
void _M_copy_from_string(const string &__s, size_t __pos, size_t __n)
Definition: _bitset.h:635
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char *__msg)
Definition: _range_errors.c:69

Member Function Documentation

◆ _Find_first()

template<size_t _Nb>
size_t bitset< _Nb >::_Find_first ( ) const
inline

Definition at line 619 of file _bitset.h.

620  { return this->_M_do_find_first(_Nb); }

◆ _Find_next()

template<size_t _Nb>
size_t bitset< _Nb >::_Find_next ( size_t  __prev) const
inline

Definition at line 623 of file _bitset.h.

624  { return this->_M_do_find_next(__prev, _Nb); }

◆ _M_copy_from_string()

template<size_t _Nb>
void bitset< _Nb >::_M_copy_from_string ( const string __s,
size_t  __pos,
size_t  __n 
)
inline

Definition at line 635 of file _bitset.h.

636  {
637  typedef typename string::traits_type _Traits;
638 #endif
639  reset();
640  size_t __tmp = _Nb;
641  const size_t __Nbits = (min) (__tmp, (min) (__n, __s.size() - __pos));
642  for ( size_t __i= 0; __i < __Nbits; ++__i) {
643  typename _Traits::int_type __k = _Traits::to_int_type(__s[__pos + __Nbits - __i - 1]);
644  // boris : widen() ?
645  if (__k == '1')
646  set(__i);
647  else if (__k != '0')
649  }
650  }
return __n
Definition: _algo.h:75
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_invalid_argument(const char *__msg)
Definition: _range_errors.c:75
size_type size() const
Definition: _string.h:400
bitset< _Nb > & set()
Definition: _bitset.h:512
#define min(a, b)
Definition: monoChain.cc:55
bitset< _Nb > & reset()
Definition: _bitset.h:530

Referenced by bitset< _Nb >::bitset(), and operator>>().

◆ _M_copy_to_string() [1/2]

template<size_t _Nb>
void bitset< _Nb >::_M_copy_to_string ( string __s) const
inline

Definition at line 656 of file _bitset.h.

658  {
659  __s.assign(_Nb, '0');
660 
661  for (size_t __i = 0; __i < _Nb; ++__i) {
662  if (_Unchecked_test(__i))
663  __s[_Nb - 1 - __i] = '1';
664  }
665  }
_Self & assign(const _Self &__s)
Definition: _string.h:548
bool _Unchecked_test(size_t __pos) const
Definition: _bitset.h:506

Referenced by operator<<(), and bitset< _Nb >::to_string().

◆ _M_copy_to_string() [2/2]

template<size_t _Nb>
void bitset< _Nb >::_M_copy_to_string ( wstring &  __s) const
inline

Definition at line 668 of file _bitset.h.

668  {
669  __s.assign(_Nb, '0');
670 
671  for (size_t __i = 0; __i < _Nb; ++__i) {
672  if (_Unchecked_test(__i))
673  __s[_Nb - 1 - __i] = '1';
674  }
675  }
bool _Unchecked_test(size_t __pos) const
Definition: _bitset.h:506

◆ _M_do_sanitize()

template<size_t _Nb>
void bitset< _Nb >::_M_do_sanitize ( )
inlineprivate

Definition at line 354 of file _bitset.h.

354  {
356  }
#define _STLP_PRIV
Definition: _dm.h:70
static void _STLP_CALL _M_do_sanitize(unsigned long &__val)
Definition: _bitset.h:333

Referenced by bitset< _Nb >::bitset(), bitset< _Nb >::flip(), bitset< _Nb >::operator<<=(), bitset< _Nb >::operator>>=(), and bitset< _Nb >::set().

◆ _Unchecked_flip()

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::_Unchecked_flip ( size_t  __pos)
inline

Definition at line 501 of file _bitset.h.

501  {
502  this->_M_getword(__pos) ^= this->_S_maskbit(__pos);
503  return *this;
504  }

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

◆ _Unchecked_reset()

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::_Unchecked_reset ( size_t  __pos)
inline

Definition at line 496 of file _bitset.h.

496  {
497  this->_M_getword(__pos) &= ~ this->_S_maskbit(__pos);
498  return *this;
499  }

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

◆ _Unchecked_set() [1/2]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::_Unchecked_set ( size_t  __pos)
inline

Definition at line 482 of file _bitset.h.

482  {
483  this->_M_getword(__pos) |= _STLP_PRIV _Base_bitset<_Words > ::_S_maskbit(__pos);
484  return *this;
485  }
#define _STLP_PRIV
Definition: _dm.h:70
static _WordT _STLP_CALL _S_maskbit(size_t __pos)
Definition: _bitset.h:128

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

◆ _Unchecked_set() [2/2]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::_Unchecked_set ( size_t  __pos,
int  __val 
)
inline

Definition at line 487 of file _bitset.h.

487  {
488  if (__val)
489  this->_M_getword(__pos) |= this->_S_maskbit(__pos);
490  else
491  this->_M_getword(__pos) &= ~ this->_S_maskbit(__pos);
492 
493  return *this;
494  }
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656

◆ _Unchecked_test()

template<size_t _Nb>
bool bitset< _Nb >::_Unchecked_test ( size_t  __pos) const
inline

Definition at line 506 of file _bitset.h.

506  {
507  return (this->_M_getword(__pos) & this->_S_maskbit(__pos)) != __STATIC_CAST(_WordT,0);
508  }
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
unsigned long _WordT
Definition: _bitset.h:358

Referenced by bitset< _Nb >::_M_copy_to_string(), bitset< _Nb >::operator[](), and bitset< _Nb >::test().

◆ any()

template<size_t _Nb>
bool bitset< _Nb >::any ( ) const
inline

Definition at line 599 of file _bitset.h.

599 { return this->_M_is_any(); }

◆ count()

template<size_t _Nb>
size_t bitset< _Nb >::count ( ) const
inline

Definition at line 581 of file _bitset.h.

581 { return this->_M_do_count(); }

◆ flip() [1/2]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::flip ( )
inline

Definition at line 542 of file _bitset.h.

542  {
543  this->_M_do_flip();
544  this->_M_do_sanitize();
545  return *this;
546  }
void _M_do_sanitize()
Definition: _bitset.h:354

Referenced by bitset< _Nb >::operator~().

◆ flip() [2/2]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::flip ( size_t  __pos)
inline

Definition at line 548 of file _bitset.h.

548  {
549  if (__pos >= _Nb)
550  __stl_throw_out_of_range("bitset");
551 
552  return _Unchecked_flip(__pos);
553  }
bitset< _Nb > & _Unchecked_flip(size_t __pos)
Definition: _bitset.h:501
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char *__msg)
Definition: _range_errors.c:69

◆ none()

template<size_t _Nb>
bool bitset< _Nb >::none ( ) const
inline

Definition at line 600 of file _bitset.h.

600 { return !this->_M_is_any(); }

◆ operator!=()

template<size_t _Nb>
bool bitset< _Nb >::operator!= ( const bitset< _Nb > &  __rhs) const
inline

Definition at line 588 of file _bitset.h.

588  {
589  return !this->_M_is_equal(__rhs);
590  }

◆ operator&=()

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::operator&= ( const bitset< _Nb > &  __rhs)
inline

Definition at line 450 of file _bitset.h.

450  {
451  this->_M_do_and(__rhs);
452  return *this;
453  }

◆ operator<<()

template<size_t _Nb>
bitset<_Nb> bitset< _Nb >::operator<< ( size_t  __pos) const
inline

Definition at line 602 of file _bitset.h.

602  {
603  bitset<_Nb> __result(*this);
604  __result <<= __pos ; return __result;
605  }

◆ operator<<=()

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::operator<<= ( size_t  __pos)
inline

Definition at line 465 of file _bitset.h.

465  {
466  this->_M_do_left_shift(__pos);
467  this->_M_do_sanitize();
468  return *this;
469  }
void _M_do_sanitize()
Definition: _bitset.h:354

◆ operator==()

template<size_t _Nb>
bool bitset< _Nb >::operator== ( const bitset< _Nb > &  __rhs) const
inline

Definition at line 585 of file _bitset.h.

585  {
586  return this->_M_is_equal(__rhs);
587  }

◆ operator>>()

template<size_t _Nb>
bitset<_Nb> bitset< _Nb >::operator>> ( size_t  __pos) const
inline

Definition at line 606 of file _bitset.h.

606  {
607  bitset<_Nb> __result(*this);
608  __result >>= __pos ; return __result;
609  }

◆ operator>>=()

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::operator>>= ( size_t  __pos)
inline

Definition at line 471 of file _bitset.h.

471  {
472  this->_M_do_right_shift(__pos);
473  this->_M_do_sanitize();
474  return *this;
475  }
void _M_do_sanitize()
Definition: _bitset.h:354

◆ operator[]() [1/2]

template<size_t _Nb>
reference bitset< _Nb >::operator[] ( size_t  __pos)
inline

Definition at line 561 of file _bitset.h.

561 { return reference(*this,__pos); }
friend struct reference
Definition: _bitset.h:359

◆ operator[]() [2/2]

template<size_t _Nb>
bool bitset< _Nb >::operator[] ( size_t  __pos) const
inline

Definition at line 562 of file _bitset.h.

562 { return _Unchecked_test(__pos); }
bool _Unchecked_test(size_t __pos) const
Definition: _bitset.h:506

◆ operator^=()

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::operator^= ( const bitset< _Nb > &  __rhs)
inline

Definition at line 460 of file _bitset.h.

460  {
461  this->_M_do_xor(__rhs);
462  return *this;
463  }

◆ operator|=()

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::operator|= ( const bitset< _Nb > &  __rhs)
inline

Definition at line 455 of file _bitset.h.

455  {
456  this->_M_do_or(__rhs);
457  return *this;
458  }

◆ operator~()

template<size_t _Nb>
bitset<_Nb> bitset< _Nb >::operator~ ( ) const
inline

Definition at line 555 of file _bitset.h.

555  {
556  return bitset<_Nb>(*this).flip();
557  }
bitset< _Nb > & flip()
Definition: _bitset.h:542

◆ reset() [1/2]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::reset ( void  )
inline

Definition at line 530 of file _bitset.h.

530  {
531  this->_M_do_reset();
532  return *this;
533  }

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

◆ reset() [2/2]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::reset ( size_t  __pos)
inline

Definition at line 535 of file _bitset.h.

535  {
536  if (__pos >= _Nb)
537  __stl_throw_out_of_range("bitset");
538 
539  return _Unchecked_reset(__pos);
540  }
bitset< _Nb > & _Unchecked_reset(size_t __pos)
Definition: _bitset.h:496
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char *__msg)
Definition: _range_errors.c:69

◆ set() [1/3]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::set ( )
inline

Definition at line 512 of file _bitset.h.

512  {
513  this->_M_do_set();
514  this->_M_do_sanitize();
515  return *this;
516  }
void _M_do_sanitize()
Definition: _bitset.h:354

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

◆ set() [2/3]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::set ( size_t  __pos)
inline

Definition at line 518 of file _bitset.h.

518  {
519  if (__pos >= _Nb)
520  __stl_throw_out_of_range("bitset");
521  return _Unchecked_set(__pos);
522  }
bitset< _Nb > & _Unchecked_set(size_t __pos)
Definition: _bitset.h:482
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char *__msg)
Definition: _range_errors.c:69

◆ set() [3/3]

template<size_t _Nb>
bitset<_Nb>& bitset< _Nb >::set ( size_t  __pos,
int  __val 
)
inline

Definition at line 524 of file _bitset.h.

524  {
525  if (__pos >= _Nb)
526  __stl_throw_out_of_range("bitset");
527  return _Unchecked_set(__pos, __val);
528  }
bitset< _Nb > & _Unchecked_set(size_t __pos)
Definition: _bitset.h:482
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char *__msg)
Definition: _range_errors.c:69

◆ size()

template<size_t _Nb>
size_t bitset< _Nb >::size ( ) const
inline

Definition at line 583 of file _bitset.h.

583 { return _Nb; }

◆ test()

template<size_t _Nb>
bool bitset< _Nb >::test ( size_t  __pos) const
inline

Definition at line 592 of file _bitset.h.

592  {
593  if (__pos >= _Nb)
594  __stl_throw_out_of_range("bitset");
595 
596  return _Unchecked_test(__pos);
597  }
bool _Unchecked_test(size_t __pos) const
Definition: _bitset.h:506
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char *__msg)
Definition: _range_errors.c:69

◆ to_string()

template<size_t _Nb>
string bitset< _Nb >::to_string ( ) const
inline

Definition at line 574 of file _bitset.h.

574  {
575  string __result;
576  _M_copy_to_string(__result);
577  return __result;
578  }
void _M_copy_to_string(string &__s) const
Definition: _bitset.h:656

◆ to_ulong()

template<size_t _Nb>
unsigned long bitset< _Nb >::to_ulong ( ) const
inline

Definition at line 564 of file _bitset.h.

564 { return this->_M_do_to_ulong(); }

Friends And Related Function Documentation

◆ reference

template<size_t _Nb>
friend struct reference
friend

Definition at line 359 of file _bitset.h.

Referenced by bitset< _Nb >::operator[]().


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