mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-19 04:12:09 +00:00
Deprecate the names "find_first", "find_first_off", "find_next", "find_next_off"
Reason: Some people expressed a dislike for the name "find_first_off",
saying it causes confusion with "find_first_of" (although a
find_first_of() wouldn't make much sense for a bitset), so we choose a
new set of consistent names:
find_first() → find_first_one()
find_first_off() → find_first_zero()
find_next() → find_next_one()
find_next_off() → find_next_zero()
.
This commit is contained in:
@@ -1249,6 +1249,11 @@ public:
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 bool intersects( const dynamic_bitset & b ) const;
|
||||
|
||||
//! A deprecated synonym for `find_first_one()`.
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DEPRECATED( "Use find_first_one(), instead" )
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first( size_type pos = 0 ) const;
|
||||
|
||||
//! Finds the first set bit in `*this` with an index >= `pos`,
|
||||
//! if any.
|
||||
//!
|
||||
@@ -1260,8 +1265,13 @@ public:
|
||||
//! \par Throws
|
||||
//! Nothing.
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first( size_type pos = 0 ) const;
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first_one( size_type pos = 0 ) const;
|
||||
|
||||
//! A deprecated synonym for `find_first_zero()`.
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DEPRECATED( "Use find_first_zero(), instead" )
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first_off( size_type pos = 0 ) const;
|
||||
|
||||
//! Finds the first unset bit in `*this` with an index >= `pos`,
|
||||
//! if any.
|
||||
//!
|
||||
@@ -1276,7 +1286,12 @@ public:
|
||||
//! \par Throws
|
||||
//! Nothing.
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first_off( size_type pos = 0 ) const;
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first_zero( size_type pos = 0 ) const;
|
||||
|
||||
//! A deprecated synonym for `find_next_one()`.
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DEPRECATED( "Use find_next_one(), instead" )
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next( size_type pos ) const;
|
||||
|
||||
//! Finds the first bit set in `*this` with an index > `pos`, if
|
||||
//! any.
|
||||
@@ -1291,7 +1306,12 @@ public:
|
||||
//! \par Throws
|
||||
//! Nothing.
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next( size_type pos ) const;
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next_one( size_type pos ) const;
|
||||
|
||||
//! A deprecated synonym for `find_next_zero()`.
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DEPRECATED( "Use find_next_zero(), instead" )
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next_off( size_type pos ) const;
|
||||
|
||||
//! Finds the first unset bit in `*this` with an index > `pos`,
|
||||
//! if any.
|
||||
@@ -1303,7 +1323,7 @@ public:
|
||||
//! The lowest index `i` greater than `pos` such that bit `i` is
|
||||
//! unset, or `npos` if no such index exists.
|
||||
// -----------------------------------------------------------------------
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next_off( size_type pos ) const;
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next_zero( size_type pos ) const;
|
||||
|
||||
template< typename B, typename A >
|
||||
friend BOOST_DYNAMIC_BITSET_CONSTEXPR20 bool operator==( const dynamic_bitset< B, A > & a, const dynamic_bitset< B, A > & b );
|
||||
|
||||
@@ -1207,7 +1207,7 @@ dynamic_bitset< Block, AllocatorOrContainer >::
|
||||
|
||||
// Check for overflows. This may be a performance burden on very large
|
||||
// bitsets but is required by the specification, sorry.
|
||||
if ( find_first( ulong_width ) != npos ) {
|
||||
if ( find_first_one( ulong_width ) != npos ) {
|
||||
BOOST_THROW_EXCEPTION( std::overflow_error( "boost::dynamic_bitset::to_ulong overflow" ) );
|
||||
}
|
||||
|
||||
@@ -1392,6 +1392,13 @@ dynamic_bitset< Block, AllocatorOrContainer >::m_do_find_from( size_type first_b
|
||||
template< typename Block, typename AllocatorOrContainer >
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
|
||||
dynamic_bitset< Block, AllocatorOrContainer >::find_first( size_type pos ) const
|
||||
{
|
||||
return find_first_one( pos );
|
||||
}
|
||||
|
||||
template< typename Block, typename AllocatorOrContainer >
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
|
||||
dynamic_bitset< Block, AllocatorOrContainer >::find_first_one( size_type pos ) const
|
||||
{
|
||||
const size_type sz = size();
|
||||
if ( pos >= sz ) {
|
||||
@@ -1412,6 +1419,13 @@ dynamic_bitset< Block, AllocatorOrContainer >::find_first( size_type pos ) const
|
||||
template< typename Block, typename AllocatorOrContainer >
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
|
||||
dynamic_bitset< Block, AllocatorOrContainer >::find_first_off( size_type pos ) const
|
||||
{
|
||||
return find_first_zero( pos );
|
||||
}
|
||||
|
||||
template< typename Block, typename AllocatorOrContainer >
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
|
||||
dynamic_bitset< Block, AllocatorOrContainer >::find_first_zero( size_type pos ) const
|
||||
{
|
||||
if ( pos >= size() ) {
|
||||
return npos;
|
||||
@@ -1439,19 +1453,33 @@ dynamic_bitset< Block, AllocatorOrContainer >::find_first_off( size_type pos ) c
|
||||
template< typename Block, typename AllocatorOrContainer >
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
|
||||
dynamic_bitset< Block, AllocatorOrContainer >::find_next( size_type pos ) const
|
||||
{
|
||||
return find_next_one( pos );
|
||||
}
|
||||
|
||||
template< typename Block, typename AllocatorOrContainer >
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
|
||||
dynamic_bitset< Block, AllocatorOrContainer >::find_next_one( size_type pos ) const
|
||||
{
|
||||
return pos == npos
|
||||
? npos
|
||||
: find_first( pos + 1 );
|
||||
: find_first_one( pos + 1 );
|
||||
}
|
||||
|
||||
template< typename Block, typename AllocatorOrContainer >
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
|
||||
dynamic_bitset< Block, AllocatorOrContainer >::find_next_off( size_type pos ) const
|
||||
{
|
||||
return find_next_zero( pos );
|
||||
}
|
||||
|
||||
template< typename Block, typename AllocatorOrContainer >
|
||||
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
|
||||
dynamic_bitset< Block, AllocatorOrContainer >::find_next_zero( size_type pos ) const
|
||||
{
|
||||
return pos == npos
|
||||
? npos
|
||||
: find_first_off( pos + 1 );
|
||||
: find_first_zero( pos + 1 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -1091,8 +1091,8 @@ struct bitset_test
|
||||
find_first( const Bitset & b, typename Bitset::size_type offset = 0, bool value = true )
|
||||
{
|
||||
const typename Bitset::size_type result = value
|
||||
? b.find_first( offset )
|
||||
: b.find_first_off( offset );
|
||||
? b.find_first_one( offset )
|
||||
: b.find_first_zero( offset );
|
||||
|
||||
// find first bit with value `value` from offset onwards, if any
|
||||
typename Bitset::size_type i = offset;
|
||||
@@ -1112,9 +1112,9 @@ struct bitset_test
|
||||
{
|
||||
find_first( b, pos, value);
|
||||
if ( value ) {
|
||||
BOOST_TEST( next_bit_on( b, pos ) == b.find_next( pos ) );
|
||||
BOOST_TEST( next_bit_on( b, pos ) == b.find_next_one( pos ) );
|
||||
} else {
|
||||
BOOST_TEST( next_bit_off( b, pos ) == b.find_next_off( pos ) );
|
||||
BOOST_TEST( next_bit_off( b, pos ) == b.find_next_zero( pos ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ run_test_cases()
|
||||
Tests::intersects( a, b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test find_first
|
||||
// Test find_first_one/find_first_zero
|
||||
{
|
||||
// empty bitset
|
||||
bitset_type b;
|
||||
@@ -334,7 +334,7 @@ run_test_cases()
|
||||
Tests::find_first( b, 0, false );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test find_next, find_next_off, offset find_first and offset find_first_off
|
||||
// Test find_next_one, find_next_zero
|
||||
{
|
||||
// empty bitset
|
||||
bitset_type b;
|
||||
@@ -350,7 +350,7 @@ run_test_cases()
|
||||
Tests::find_pos( b, b.npos, false );
|
||||
}
|
||||
{
|
||||
// bitset of size 1 (find_next can never find)
|
||||
// bitset of size 1 (find_next_one or find_next_zero can never find)
|
||||
bitset_type b( 1, 1ul );
|
||||
|
||||
// check
|
||||
|
||||
Reference in New Issue
Block a user