mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-24 05:52:09 +00:00
Compare commits
17 Commits
boost-1.29
...
boost-1.30
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b1fcc1e54 | ||
|
|
4a44c8fdf5 | ||
|
|
c3ecab1edc | ||
|
|
2588fb047a | ||
|
|
87ac6004b2 | ||
|
|
571ea640e1 | ||
|
|
6fc5896e72 | ||
|
|
a5cad3ad88 | ||
|
|
f4a45420c0 | ||
|
|
4dbeae0c34 | ||
|
|
8424ddf9aa | ||
|
|
644da01f9c | ||
|
|
3a15e6bc7d | ||
|
|
d02ea45d32 | ||
|
|
944e625455 | ||
|
|
43a44321d0 | ||
|
|
946403a28d |
@@ -66,7 +66,7 @@ struct bitset_test {
|
||||
if (! (str[i] == '0' || str[i] == '1'))
|
||||
any_non_zero_or_one = true;
|
||||
if (any_non_zero_or_one) {
|
||||
// Input does not satisfy precondition.
|
||||
// Input does not satisfy precondition.
|
||||
} else {
|
||||
// Construct an object, initializing the first M bit position to
|
||||
// values determined from the corresponding characters in the
|
||||
@@ -97,10 +97,10 @@ struct bitset_test {
|
||||
Bitset bset(blocks.begin(), blocks.end());
|
||||
std::size_t n = blocks.size();
|
||||
for (std::size_t b = 0; b < n; ++b) {
|
||||
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
|
||||
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
|
||||
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
|
||||
}
|
||||
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
|
||||
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
|
||||
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -108,10 +108,10 @@ struct bitset_test {
|
||||
boost::from_block_range(blocks.begin(), blocks.end(), bset);
|
||||
std::size_t n = blocks.size();
|
||||
for (std::size_t b = 0; b < n; ++b) {
|
||||
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
|
||||
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
|
||||
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
|
||||
}
|
||||
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
|
||||
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
|
||||
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,15 +531,15 @@ struct bitset_test {
|
||||
{
|
||||
if (a.is_subset_of(b)) {
|
||||
for (std::size_t I = 0; I < a.size(); ++I)
|
||||
if (a[I])
|
||||
BOOST_CHECK(b[I]);
|
||||
if (a[I])
|
||||
BOOST_CHECK(b[I]);
|
||||
} else {
|
||||
bool is_subset = true;
|
||||
for (std::size_t I = 0; I < a.size(); ++I)
|
||||
if (a[I] && !b[I]) {
|
||||
is_subset = false;
|
||||
break;
|
||||
}
|
||||
if (a[I] && !b[I]) {
|
||||
is_subset = false;
|
||||
break;
|
||||
}
|
||||
BOOST_CHECK(is_subset == false);
|
||||
}
|
||||
}
|
||||
@@ -548,16 +548,16 @@ struct bitset_test {
|
||||
{
|
||||
if (a.is_proper_subset_of(b)) {
|
||||
for (std::size_t I = 0; I < a.size(); ++I)
|
||||
if (a[I])
|
||||
BOOST_CHECK(b[I]);
|
||||
if (a[I])
|
||||
BOOST_CHECK(b[I]);
|
||||
BOOST_CHECK(a.count() < b.count());
|
||||
} else {
|
||||
bool is_subset = true;
|
||||
for (std::size_t I = 0; I < a.size(); ++I)
|
||||
if (a[I] && !b[I]) {
|
||||
is_subset = false;
|
||||
break;
|
||||
}
|
||||
if (a[I] && !b[I]) {
|
||||
is_subset = false;
|
||||
break;
|
||||
}
|
||||
BOOST_CHECK(is_subset == false || a.count() >= b.count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
// (C) Copyright Jeremy Siek 2001.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all
|
||||
// copies. This software is provided "as is" without express or
|
||||
// implied warranty, and with no claim as to its suitability for any
|
||||
// purpose.
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cmath> // for pow
|
||||
@@ -29,7 +36,7 @@ void run_test_cases()
|
||||
std::size_t N, ul_size = CHAR_BIT * sizeof(unsigned long),
|
||||
block_size = CHAR_BIT * sizeof(Block);
|
||||
unsigned long numbers[] = { 0, 40247,
|
||||
std::numeric_limits<unsigned long>::max() };
|
||||
std::numeric_limits<unsigned long>::max() };
|
||||
|
||||
//=====================================================================
|
||||
// Test construction from unsigned long
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
// (C) Copyright Jeremy Siek 2001.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all
|
||||
// copies. This software is provided "as is" without express or
|
||||
// implied warranty, and with no claim as to its suitability for any
|
||||
// purpose.
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cmath> // for pow
|
||||
@@ -230,3 +237,4 @@ test_main(int argc, char*[])
|
||||
run_test_cases<unsigned long>();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
// (C) Copyright Jeremy Siek 2001.
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all
|
||||
// copies. This software is provided "as is" without express or
|
||||
// implied warranty, and with no claim as to its suitability for any
|
||||
// purpose.
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cmath> // for pow
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all
|
||||
@@ -45,7 +45,7 @@ namespace boost {
|
||||
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
class dynamic_bitset_base :
|
||||
class dynamic_bitset_base :
|
||||
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
|
||||
protected
|
||||
#else
|
||||
@@ -77,7 +77,7 @@ namespace boost {
|
||||
this->m_alloc.deallocate(m_bits, m_num_blocks);
|
||||
}
|
||||
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
|
||||
protected:
|
||||
protected:
|
||||
#endif
|
||||
Block* m_bits;
|
||||
size_type m_num_bits;
|
||||
@@ -87,7 +87,7 @@ namespace boost {
|
||||
static size_type offset(size_type bit){ return bit % bits_per_block; } // [gps]
|
||||
static Block mask1(size_type bit) { return Block(1) << offset(bit); }
|
||||
static Block mask0(size_type bit) { return ~(Block(1) << offset(bit)); }
|
||||
static size_type calc_num_blocks(size_type num_bits)
|
||||
static size_type calc_num_blocks(size_type num_bits)
|
||||
{ return (num_bits + bits_per_block - 1) / bits_per_block; }
|
||||
};
|
||||
|
||||
@@ -127,13 +127,13 @@ namespace boost {
|
||||
{
|
||||
// Automatically generated by GPTableGen.exe v.1.0
|
||||
//
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
|
||||
};
|
||||
|
||||
@@ -142,26 +142,26 @@ namespace boost {
|
||||
|
||||
template <typename BlockInputIterator>
|
||||
std::size_t initial_num_blocks(BlockInputIterator first,
|
||||
BlockInputIterator last,
|
||||
std::input_iterator_tag)
|
||||
BlockInputIterator last,
|
||||
std::input_iterator_tag)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename BlockForwardIterator>
|
||||
std::size_t initial_num_blocks(BlockForwardIterator first,
|
||||
BlockForwardIterator last,
|
||||
std::forward_iterator_tag)
|
||||
BlockForwardIterator last,
|
||||
std::forward_iterator_tag)
|
||||
{
|
||||
std::size_t n = 0;
|
||||
while (first != last)
|
||||
++first, ++n;
|
||||
++first, ++n;
|
||||
return n;
|
||||
}
|
||||
|
||||
template <typename BlockInputIterator>
|
||||
std::size_t initial_num_blocks(BlockInputIterator first,
|
||||
BlockInputIterator last)
|
||||
BlockInputIterator last)
|
||||
{
|
||||
typename detail::iterator_traits<BlockInputIterator>::iterator_category cat;
|
||||
return initial_num_blocks(first, last, cat);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
// With optimizations, bug fixes, and improvements by Gennaro Prota.
|
||||
|
||||
// See http://www.boost.org/libs/dynamic_bitset for documentation.
|
||||
|
||||
// -------------------------------------
|
||||
// CHANGE LOG:
|
||||
//
|
||||
@@ -46,8 +48,8 @@
|
||||
#define BOOST_OLD_IOSTREAMS
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
|
||||
// in certain situations VC++ requires a redefinition of
|
||||
// default template arguments, in contrast with 14.1/12
|
||||
//
|
||||
@@ -64,7 +66,7 @@ namespace boost {
|
||||
template <typename Block, typename Allocator>
|
||||
#endif
|
||||
|
||||
class dynamic_bitset :
|
||||
class dynamic_bitset :
|
||||
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
|
||||
private
|
||||
#else
|
||||
@@ -86,7 +88,7 @@ public:
|
||||
friend class dynamic_bitset<Block, Allocator>;
|
||||
dynamic_bitset* bs;
|
||||
size_type bit;
|
||||
reference(); // intentionally not implemented
|
||||
reference(); // intentionally not implemented
|
||||
reference(dynamic_bitset& bs_, size_type bit_) : bs(&bs_), bit(bit_){ }
|
||||
public:
|
||||
reference& operator=(bool value) // for b[i] = x
|
||||
@@ -95,30 +97,30 @@ public:
|
||||
bs->set(bit);
|
||||
else
|
||||
bs->reset(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator|=(bool value) // for b[i] |= x
|
||||
{
|
||||
if (value)
|
||||
bs->set(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator&=(bool value) // for b[i] &= x
|
||||
{
|
||||
if (! (value && bs->test(bit)))
|
||||
bs->reset(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator^=(bool value) // for b[i] ^= x
|
||||
{
|
||||
bs->set(bit, bs->test(bit) ^ value);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator-=(bool value) // for b[i] -= x
|
||||
{
|
||||
if (!value)
|
||||
bs->reset(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator=(const reference& j) // for b[i] = b[j]
|
||||
{
|
||||
@@ -126,34 +128,34 @@ public:
|
||||
bs->set(bit);
|
||||
else
|
||||
bs->reset(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator|=(const reference& j) // for b[i] |= b[j]
|
||||
{
|
||||
if (j.bs->test(j.bit))
|
||||
bs->set(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator&=(const reference& j) // for b[i] &= b[j]
|
||||
{
|
||||
if (! (j.bs->test(j.bit) && bs->test(bit)))
|
||||
bs->reset(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator^=(const reference& j) // for b[i] ^= b[j]
|
||||
{
|
||||
bs->set(bit, bs->test(bit) ^ j.bs->test(j.bit));
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
reference& operator-=(const reference& j) // for b[i] -= b[j]
|
||||
{
|
||||
if (!j.bs->test(j.bit))
|
||||
bs->reset(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
bool operator~() const // flips the bit
|
||||
{
|
||||
return ! bs->test(bit);
|
||||
return ! bs->test(bit);
|
||||
}
|
||||
operator bool() const // for x = b[i]
|
||||
{
|
||||
@@ -162,7 +164,7 @@ public:
|
||||
reference& flip() // for b[i].flip();
|
||||
{
|
||||
bs->flip(bit);
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
typedef bool const_reference;
|
||||
@@ -179,7 +181,7 @@ public:
|
||||
#if defined(BOOST_OLD_IOSTREAMS)
|
||||
explicit
|
||||
dynamic_bitset(const std::string& s,
|
||||
std::string::size_type pos = 0,
|
||||
std::string::size_type pos = 0,
|
||||
std::string::size_type n = std::string::npos,
|
||||
const Allocator& alloc = Allocator())
|
||||
: detail::dynamic_bitset_base<Block, Allocator>
|
||||
@@ -189,9 +191,9 @@ public:
|
||||
// in the code below are to avoid a g++ 3.2 bug and a Borland bug. -JGS
|
||||
template <typename CharT, typename Traits, typename Alloc>
|
||||
explicit
|
||||
dynamic_bitset(const std::basic_string<CharT, Traits, Alloc>& s,
|
||||
typename std::basic_string<CharT, Traits, Alloc>::size_type pos = 0,
|
||||
typename std::basic_string<CharT, Traits, Alloc>::size_type n
|
||||
dynamic_bitset(const std::basic_string<CharT, Traits, Alloc>& s,
|
||||
typename std::basic_string<CharT, Traits, Alloc>::size_type pos = 0,
|
||||
typename std::basic_string<CharT, Traits, Alloc>::size_type n
|
||||
= (std::basic_string<CharT, Traits, Alloc>::npos),
|
||||
const Allocator& alloc = Allocator())
|
||||
: detail::dynamic_bitset_base<Block, Allocator>
|
||||
@@ -200,7 +202,7 @@ public:
|
||||
{
|
||||
// Locate sub string
|
||||
assert(pos <= s.length());
|
||||
from_string(s, pos, std::min(n, s.size() - pos));
|
||||
from_string(s, pos, std::min(n, s.size() - pos));
|
||||
}
|
||||
|
||||
// The first bit in *first is the least significant bit, and the
|
||||
@@ -209,8 +211,8 @@ public:
|
||||
dynamic_bitset(BlockInputIterator first, BlockInputIterator last,
|
||||
const Allocator& alloc = Allocator())
|
||||
: detail::dynamic_bitset_base<Block, Allocator>
|
||||
(detail::initial_num_blocks(first, last)
|
||||
* bits_per_block, alloc)
|
||||
(detail::initial_num_blocks(first, last)
|
||||
* bits_per_block, alloc)
|
||||
{
|
||||
if (first != last) {
|
||||
if (this->m_num_bits == 0) { // dealing with input iterators
|
||||
@@ -220,7 +222,7 @@ public:
|
||||
for (std::size_t i = 0; first != last; ++first, ++i)
|
||||
set_block_(i, *first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +261,7 @@ public:
|
||||
append(*first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +293,7 @@ public:
|
||||
bool operator[](size_type pos) const { return test_(pos); } //[gps]
|
||||
|
||||
unsigned long to_ulong() const;
|
||||
|
||||
|
||||
size_type size() const;
|
||||
size_type num_blocks() const;
|
||||
|
||||
@@ -302,17 +304,17 @@ public:
|
||||
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
|
||||
// lexicographical comparison
|
||||
template <typename B, typename A>
|
||||
friend bool operator==(const dynamic_bitset<B, A>& a,
|
||||
friend bool operator==(const dynamic_bitset<B, A>& a,
|
||||
const dynamic_bitset<B, A>& b);
|
||||
template <typename B, typename A>
|
||||
friend bool operator<(const dynamic_bitset<B, A>& a,
|
||||
friend bool operator<(const dynamic_bitset<B, A>& a,
|
||||
const dynamic_bitset<B, A>& b);
|
||||
template <typename B, typename A>
|
||||
friend bool operator>(const dynamic_bitset<B, A>& a,
|
||||
friend bool operator>(const dynamic_bitset<B, A>& a,
|
||||
const dynamic_bitset<B, A>& b);
|
||||
|
||||
template <typename B, typename A, typename BlockOutputIterator>
|
||||
friend void to_block_range(const dynamic_bitset<B, A>& b,
|
||||
friend void to_block_range(const dynamic_bitset<B, A>& b,
|
||||
BlockOutputIterator result);
|
||||
|
||||
template <typename BlockIterator, typename B, typename A>
|
||||
@@ -320,7 +322,7 @@ public:
|
||||
dynamic_bitset<B, A>& result);
|
||||
|
||||
template <typename B, typename A, typename CharT, typename Alloc>
|
||||
friend void dump_to_string(const dynamic_bitset<B, A>& b,
|
||||
friend void dump_to_string(const dynamic_bitset<B, A>& b,
|
||||
std::basic_string<CharT, Alloc>& s);
|
||||
#endif
|
||||
|
||||
@@ -345,12 +347,12 @@ public:
|
||||
|
||||
// Assumes string contains only 0's and 1's
|
||||
for (size_type i = 0; i < tot; ++i) {
|
||||
if (s[pos + tot - i - 1] == '1') {
|
||||
if (s[pos + tot - i - 1] == '1') {
|
||||
set_(i);
|
||||
} else {
|
||||
assert(s[pos + tot - i - 1] == '0');
|
||||
assert(s[pos + tot - i - 1] == '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
@@ -359,25 +361,25 @@ public:
|
||||
|
||||
// comparison
|
||||
template <typename Block, typename Allocator>
|
||||
bool operator!=(const dynamic_bitset<Block, Allocator>& a,
|
||||
bool operator!=(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b);
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
bool operator<=(const dynamic_bitset<Block, Allocator>& a,
|
||||
bool operator<=(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b);
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
bool operator>(const dynamic_bitset<Block, Allocator>& a,
|
||||
bool operator>(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b);
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
bool operator>=(const dynamic_bitset<Block, Allocator>& a,
|
||||
bool operator>=(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b);
|
||||
|
||||
// stream operators
|
||||
#ifdef BOOST_OLD_IOSTREAMS
|
||||
template <typename Block, typename Allocator>
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
const dynamic_bitset<Block, Allocator>& b);
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
@@ -385,24 +387,24 @@ std::istream& operator>>(std::istream& is, dynamic_bitset<Block,Allocator>& b);
|
||||
#else
|
||||
template <typename CharT, typename Traits, typename Block, typename Allocator>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os,
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os,
|
||||
const dynamic_bitset<Block, Allocator>& b);
|
||||
|
||||
template <typename CharT, typename Traits, typename Block, typename Allocator>
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
dynamic_bitset<Block, Allocator>& b);
|
||||
#endif
|
||||
|
||||
// bitset operations
|
||||
template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>
|
||||
operator&(const dynamic_bitset<Block, Allocator>& b1,
|
||||
operator&(const dynamic_bitset<Block, Allocator>& b1,
|
||||
const dynamic_bitset<Block, Allocator>& b2);
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>
|
||||
operator|(const dynamic_bitset<Block, Allocator>& b1,
|
||||
operator|(const dynamic_bitset<Block, Allocator>& b1,
|
||||
const dynamic_bitset<Block, Allocator>& b2);
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
@@ -417,13 +419,13 @@ operator-(const dynamic_bitset<Block, Allocator>& b1,
|
||||
|
||||
|
||||
template <typename Block, typename Allocator, typename CharT, typename Alloc>
|
||||
void
|
||||
to_string(const dynamic_bitset<Block, Allocator>& b,
|
||||
void
|
||||
to_string(const dynamic_bitset<Block, Allocator>& b,
|
||||
std::basic_string<CharT, Alloc>& s);
|
||||
|
||||
template <typename Block, typename Allocator, typename BlockOutputIterator>
|
||||
void
|
||||
to_block_range(const dynamic_bitset<Block, Allocator>& b,
|
||||
to_block_range(const dynamic_bitset<Block, Allocator>& b,
|
||||
BlockOutputIterator result);
|
||||
|
||||
template <typename BlockIterator, typename B, typename A>
|
||||
@@ -437,7 +439,7 @@ from_block_range(BlockIterator first, BlockIterator last,
|
||||
#ifdef BOOST_OLD_IOSTREAMS
|
||||
template <typename Block, typename Allocator>
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& os,
|
||||
operator<<(std::ostream& os,
|
||||
const typename dynamic_bitset<Block, Allocator>::reference& br)
|
||||
{
|
||||
return os << (bool)br;
|
||||
@@ -445,7 +447,7 @@ operator<<(std::ostream& os,
|
||||
#else
|
||||
template <typename CharT, typename Traits, typename Block, typename Allocator>
|
||||
inline std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os,
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os,
|
||||
const typename dynamic_bitset<Block, Allocator>::reference& br)
|
||||
{
|
||||
return os << (bool)br;
|
||||
@@ -645,9 +647,9 @@ dynamic_bitset<Block, Allocator>::operator<<=(size_type n)
|
||||
size_type const last = this->m_num_blocks - 1; // m_num_blocks is >= 1
|
||||
size_type const div = n / bits_per_block; // div is <= last
|
||||
size_type const r = n % bits_per_block;
|
||||
|
||||
|
||||
// PRE: div != 0 or r != 0
|
||||
|
||||
|
||||
if (r != 0) {
|
||||
|
||||
block_type const rs = bits_per_block - r;
|
||||
@@ -656,7 +658,7 @@ dynamic_bitset<Block, Allocator>::operator<<=(size_type n)
|
||||
this->m_bits[i+div] = (this->m_bits[i] << r) | (this->m_bits[i-1] >> rs);
|
||||
}
|
||||
this->m_bits[div] = this->m_bits[0] << r;
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
for (size_type i = last-div; i>0; --i) {
|
||||
@@ -664,12 +666,12 @@ dynamic_bitset<Block, Allocator>::operator<<=(size_type n)
|
||||
}
|
||||
this->m_bits[div] = this->m_bits[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// div blocks are zero filled at the less significant end
|
||||
std::fill(this->m_bits, this->m_bits+div, static_cast<block_type>(0));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -692,7 +694,7 @@ dynamic_bitset<Block, Allocator>::operator>>=(size_type n)
|
||||
size_type i;
|
||||
for (i = 0; i < this->m_num_bits - n; ++i)
|
||||
set_(i,test_(i+n));
|
||||
|
||||
|
||||
for (i = this->m_num_bits - n; i < this->m_num_bits; ++i)
|
||||
reset_(i);
|
||||
}
|
||||
@@ -705,7 +707,7 @@ dynamic_bitset<Block, Allocator>::operator>>=(size_type n)
|
||||
// NOTE: this assumes that within a single block bits are
|
||||
// numbered from right to left. G.P.S.
|
||||
//
|
||||
// static Block offset(size_type bit)
|
||||
// static Block offset(size_type bit)
|
||||
// { return bit % bits_per_block; }
|
||||
//
|
||||
//
|
||||
@@ -726,7 +728,7 @@ dynamic_bitset<B, A> & dynamic_bitset<B, A>::operator>>=(size_type n) {
|
||||
size_type const last = this->m_num_blocks - 1; // m_num_blocks is >= 1
|
||||
size_type const div = n / bits_per_block; // div is <= last
|
||||
size_type const r = n % bits_per_block;
|
||||
|
||||
|
||||
// PRE: div != 0 or r != 0
|
||||
|
||||
if (r != 0) {
|
||||
@@ -748,8 +750,8 @@ dynamic_bitset<B, A> & dynamic_bitset<B, A>::operator>>=(size_type n) {
|
||||
// this->m_bits[last-div] = this->m_bits[last] >> 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// div blocks are zero filled at the most significant end
|
||||
std::fill(this->m_bits+(this->m_num_blocks-div), this->m_bits+this->m_num_blocks, static_cast<block_type>(0));
|
||||
}
|
||||
@@ -892,7 +894,7 @@ dynamic_bitset<Block, Allocator>::count() const
|
||||
}
|
||||
|
||||
The actual algorithm used is based on using a lookup
|
||||
table.
|
||||
table.
|
||||
|
||||
|
||||
The basic idea of the method is to pick up X bits at a time
|
||||
@@ -900,7 +902,7 @@ table.
|
||||
the binary representation of a number N. Then, to use a table
|
||||
of 1<<X elements where table[N] is the number of '1' digits
|
||||
in the binary representation of N (i.e. in our X bits).
|
||||
|
||||
|
||||
Note that the table can be oversized (i.e. can even have more
|
||||
than 1<<X elements; in that case only the first 1<<X will be
|
||||
actually used) but it cannot be undersized.
|
||||
@@ -949,7 +951,7 @@ dynamic_bitset<Block, Allocator>::count() const
|
||||
do {
|
||||
num += detail::count<>::table[value & ((1<<max_bit)-1)];
|
||||
} while (value >>= max_bit);
|
||||
|
||||
|
||||
++p;
|
||||
}
|
||||
}
|
||||
@@ -964,8 +966,8 @@ dynamic_bitset<Block, Allocator>::count() const
|
||||
|
||||
// take as ref param instead?
|
||||
template <typename Block, typename Allocator, typename CharT, typename Alloc>
|
||||
void
|
||||
to_string(const dynamic_bitset<Block, Allocator>& b,
|
||||
void
|
||||
to_string(const dynamic_bitset<Block, Allocator>& b,
|
||||
std::basic_string<CharT, Alloc>& s)
|
||||
{
|
||||
s.assign(b.size(), '0');
|
||||
@@ -980,8 +982,8 @@ to_string(const dynamic_bitset<Block, Allocator>& b,
|
||||
// for debugging purposes)
|
||||
//
|
||||
template <typename B, typename A, typename CharT, typename Alloc>
|
||||
void
|
||||
dump_to_string(const dynamic_bitset<B, A>& b,
|
||||
void
|
||||
dump_to_string(const dynamic_bitset<B, A>& b,
|
||||
std::basic_string<CharT, Alloc>& s)
|
||||
{
|
||||
std::size_t const len = b.m_num_blocks * (dynamic_bitset<B, A>::bits_per_block);
|
||||
@@ -993,11 +995,11 @@ dump_to_string(const dynamic_bitset<B, A>& b,
|
||||
|
||||
template <typename Block, typename Allocator, typename BlockOutputIterator>
|
||||
void
|
||||
to_block_range(const dynamic_bitset<Block, Allocator>& b,
|
||||
to_block_range(const dynamic_bitset<Block, Allocator>& b,
|
||||
BlockOutputIterator result)
|
||||
{
|
||||
assert(b.size() != 0 || b.num_blocks() == 0);
|
||||
std::copy (b.m_bits, b.m_bits + b.m_num_blocks, result);
|
||||
std::copy (b.m_bits, b.m_bits + b.m_num_blocks, result);
|
||||
}
|
||||
|
||||
template <typename BlockIterator, typename B, typename A>
|
||||
@@ -1011,14 +1013,14 @@ from_block_range(BlockIterator first, BlockIterator last,
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
unsigned long dynamic_bitset<Block, Allocator>::
|
||||
to_ulong() const
|
||||
to_ulong() const
|
||||
{
|
||||
const std::overflow_error
|
||||
overflow("boost::bit_set::operator unsigned long()");
|
||||
|
||||
if (this->m_num_blocks == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
if (sizeof(Block) >= sizeof(unsigned long)) {
|
||||
for (size_type i = 1; i < this->m_num_blocks; ++i)
|
||||
if (this->m_bits[i])
|
||||
@@ -1102,7 +1104,7 @@ is_proper_subset_of(const dynamic_bitset<Block, Allocator>& a) const
|
||||
// comparison
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
bool operator==(const dynamic_bitset<Block, Allocator>& a,
|
||||
bool operator==(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b)
|
||||
{
|
||||
using namespace std;
|
||||
@@ -1112,7 +1114,7 @@ bool operator==(const dynamic_bitset<Block, Allocator>& a,
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
inline bool operator!=(const dynamic_bitset<Block, Allocator>& a,
|
||||
inline bool operator!=(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b)
|
||||
{
|
||||
return !(a == b);
|
||||
@@ -1145,14 +1147,14 @@ bool operator<(const dynamic_bitset<Block, Allocator>& a,
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
inline bool operator<=(const dynamic_bitset<Block, Allocator>& a,
|
||||
inline bool operator<=(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b)
|
||||
{
|
||||
return !(a > b);
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
inline bool operator>(const dynamic_bitset<Block, Allocator>& a,
|
||||
inline bool operator>(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b)
|
||||
{
|
||||
assert(a.size() == b.size());
|
||||
@@ -1178,7 +1180,7 @@ inline bool operator>(const dynamic_bitset<Block, Allocator>& a,
|
||||
}
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
inline bool operator>=(const dynamic_bitset<Block, Allocator>& a,
|
||||
inline bool operator>=(const dynamic_bitset<Block, Allocator>& a,
|
||||
const dynamic_bitset<Block, Allocator>& b)
|
||||
{
|
||||
return !(a < b);
|
||||
@@ -1282,7 +1284,7 @@ operator>>(std::basic_istream<CharT, Traits>& in_stream,
|
||||
} else {
|
||||
char c2 = Traits::to_char_type(c1);
|
||||
char c = in_stream.narrow(c2, '*');
|
||||
|
||||
|
||||
if (c == '0' || c == '1')
|
||||
tmp += c; // old dinkumware basic_string missing push_back
|
||||
else if (Traits::eq_int_type(read_buf->sputbackc(c2), Traits::eof()))
|
||||
@@ -1292,7 +1294,7 @@ operator>>(std::basic_istream<CharT, Traits>& in_stream,
|
||||
}
|
||||
}
|
||||
} // for
|
||||
|
||||
|
||||
if (tmp.empty()) // did not read in enough bits
|
||||
in_stream.setstate(std::ios_base::failbit);
|
||||
else
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all
|
||||
// copies. This software is provided "as is" without express or
|
||||
// implied warranty, and with no claim as to its suitability for any
|
||||
// purpose.
|
||||
|
||||
// See http://www.boost.org/libs/dynamic_bitset for documentation.
|
||||
|
||||
#ifndef BOOST_DYNAMIC_BITSET_FWD_HPP
|
||||
#define BOOST_DYNAMIC_BITSET_FWD_HPP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user