Blender V4.3
blender::bits Namespace Reference

Namespaces

namespace  detail
 
namespace  tests
 

Classes

class  BitGroupVector
 
class  BitIterator
 
class  BitIteratorBase
 
class  BitRef
 
class  BitSpan
 
class  BitVector
 
class  BoundedBitSpan
 
class  MutableBitIterator
 
class  MutableBitRef
 
class  MutableBitSpan
 
class  MutableBoundedBitSpan
 

Typedefs

using BitInt = uint64_t
 

Functions

bool or_bools_into_bits (Span< bool > bools, MutableBitSpan r_bits, int64_t allowed_overshoot=0)
 
BitInt mask_first_n_bits (const int64_t n)
 
BitInt mask_last_n_bits (const int64_t n)
 
BitInt mask_range_bits (const int64_t start, const int64_t size)
 
BitInt mask_single_bit (const int64_t bit_index)
 
BitIntint_containing_bit (BitInt *data, const int64_t bit_index)
 
const BitIntint_containing_bit (const BitInt *data, const int64_t bit_index)
 
std::ostream & operator<< (std::ostream &stream, const BitRef &bit)
 
std::ostream & operator<< (std::ostream &stream, const MutableBitRef &bit)
 
bool is_bounded_span (const BitSpan span)
 
std::optional< BoundedBitSpantry_get_bounded_span (const BitSpan span)
 
template<typename T >
T to_best_bit_span (const T &data)
 
std::ostream & operator<< (std::ostream &stream, const BitSpan &span)
 
std::ostream & operator<< (std::ostream &stream, const MutableBitSpan &span)
 
template<typename ExprFn , typename FirstBitSpanT , typename... BitSpanT>
void mix_into_first_expr (ExprFn &&expr, FirstBitSpanT &&first_arg, const BitSpanT &...args)
 
template<typename ExprFn , typename FirstBitSpanT , typename... BitSpanT>
bool any_set_expr (ExprFn &&expr, const FirstBitSpanT &first_arg, const BitSpanT &...args)
 
template<typename ExprFn , typename HandleFn , typename FirstBitSpanT , typename... BitSpanT>
void foreach_1_index_expr (ExprFn &&expr, HandleFn &&handle, const FirstBitSpanT &first_arg, const BitSpanT &...args)
 
template<typename BitSpanT >
void invert (BitSpanT &&data)
 
template<typename FirstBitSpanT , typename... BitSpanT>
void inplace_or (FirstBitSpanT &first_arg, const BitSpanT &...args)
 
template<typename FirstBitSpanT , typename MaskBitSpanT , typename... BitSpanT>
void inplace_or_masked (FirstBitSpanT &first_arg, const MaskBitSpanT &mask, const BitSpanT &...args)
 
template<typename FirstBitSpanT , typename... BitSpanT>
void copy_from_or (FirstBitSpanT &first_arg, const BitSpanT &...args)
 
template<typename FirstBitSpanT , typename... BitSpanT>
void inplace_and (FirstBitSpanT &first_arg, const BitSpanT &...args)
 
template<typename... BitSpanT>
void operator|= (MutableBitSpan first_arg, const BitSpanT &...args)
 
template<typename... BitSpanT>
void operator|= (MutableBoundedBitSpan first_arg, const BitSpanT &...args)
 
template<typename... BitSpanT>
void operator&= (MutableBitSpan first_arg, const BitSpanT &...args)
 
template<typename... BitSpanT>
void operator&= (MutableBoundedBitSpan first_arg, const BitSpanT &...args)
 
template<typename... BitSpanT>
bool has_common_set_bits (const BitSpanT &...args)
 
template<typename BitSpanT >
bool any_bit_set (const BitSpanT &arg)
 
template<typename... BitSpanT>
bool has_common_unset_bits (const BitSpanT &...args)
 
template<typename BitSpanT >
bool any_bit_unset (const BitSpanT &arg)
 
template<typename BitSpanT , typename Fn >
void foreach_1_index (const BitSpanT &data, Fn &&fn)
 
template<typename BitSpanT , typename Fn >
void foreach_0_index (const BitSpanT &data, Fn &&fn)
 
template<typename BitSpanT1 , typename BitSpanT2 >
bool spans_equal (const BitSpanT1 &a, const BitSpanT2 &b)
 
template<typename BitSpanT1 , typename BitSpanT2 , typename BitSpanT3 >
bool spans_equal_masked (const BitSpanT1 &a, const BitSpanT2 &b, const BitSpanT3 &mask)
 
template<typename IntT >
void bits_to_index_ranges (const BitSpan bits, IndexRangesBuilder< IntT > &builder)
 
template<int64_t InlineBufferCapacity, typename Allocator >
BoundedBitSpan to_best_bit_span (const BitVector< InlineBufferCapacity, Allocator > &data)
 
template<int64_t InlineBufferCapacity, typename Allocator >
MutableBoundedBitSpan to_best_bit_span (BitVector< InlineBufferCapacity, Allocator > &data)
 

Variables

static constexpr int64_t BitsPerInt = int64_t(sizeof(BitInt) * 8)
 
static constexpr int64_t BitToIntIndexShift
 
static constexpr BitInt BitIndexMask = (BitInt(1) << BitToIntIndexShift) - 1
 
template<typename... Args>
constexpr bool all_bounded_spans
 

Typedef Documentation

◆ BitInt

Using a large integer type is better because then it's easier to process many bits at once.

Definition at line 28 of file BLI_bit_ref.hh.

Function Documentation

◆ any_bit_set()

template<typename BitSpanT >
bool blender::bits::any_bit_set ( const BitSpanT & arg)
inline

Definition at line 257 of file BLI_bit_span_ops.hh.

References has_common_set_bits().

◆ any_bit_unset()

template<typename BitSpanT >
bool blender::bits::any_bit_unset ( const BitSpanT & arg)
inline

Definition at line 267 of file BLI_bit_span_ops.hh.

References has_common_unset_bits().

◆ any_set_expr()

template<typename ExprFn , typename FirstBitSpanT , typename... BitSpanT>
bool blender::bits::any_set_expr ( ExprFn && expr,
const FirstBitSpanT & first_arg,
const BitSpanT &... args )
inline

◆ bits_to_index_ranges()

template<typename IntT >
void blender::bits::bits_to_index_ranges ( const BitSpan bits,
IndexRangesBuilder< IntT > & builder )
inline

◆ copy_from_or()

template<typename FirstBitSpanT , typename... BitSpanT>
void blender::bits::copy_from_or ( FirstBitSpanT & first_arg,
const BitSpanT &... args )
inline

◆ foreach_0_index()

template<typename BitSpanT , typename Fn >
void blender::bits::foreach_0_index ( const BitSpanT & data,
Fn && fn )
inline

◆ foreach_1_index()

◆ foreach_1_index_expr()

template<typename ExprFn , typename HandleFn , typename FirstBitSpanT , typename... BitSpanT>
void blender::bits::foreach_1_index_expr ( ExprFn && expr,
HandleFn && handle,
const FirstBitSpanT & first_arg,
const BitSpanT &... args )
inline

◆ has_common_set_bits()

template<typename... BitSpanT>
bool blender::bits::has_common_set_bits ( const BitSpanT &... args)
inline

Definition at line 252 of file BLI_bit_span_ops.hh.

References any_set_expr().

Referenced by any_bit_set(), and blender::bke::discover_tree_zones().

◆ has_common_unset_bits()

template<typename... BitSpanT>
bool blender::bits::has_common_unset_bits ( const BitSpanT &... args)
inline

Definition at line 262 of file BLI_bit_span_ops.hh.

References any_set_expr().

Referenced by any_bit_unset().

◆ inplace_and()

template<typename FirstBitSpanT , typename... BitSpanT>
void blender::bits::inplace_and ( FirstBitSpanT & first_arg,
const BitSpanT &... args )
inline

Definition at line 223 of file BLI_bit_span_ops.hh.

References mix_into_first_expr().

Referenced by operator&=(), and operator&=().

◆ inplace_or()

template<typename FirstBitSpanT , typename... BitSpanT>
void blender::bits::inplace_or ( FirstBitSpanT & first_arg,
const BitSpanT &... args )
inline

Definition at line 198 of file BLI_bit_span_ops.hh.

References mix_into_first_expr().

Referenced by operator|=(), and operator|=().

◆ inplace_or_masked()

template<typename FirstBitSpanT , typename MaskBitSpanT , typename... BitSpanT>
void blender::bits::inplace_or_masked ( FirstBitSpanT & first_arg,
const MaskBitSpanT & mask,
const BitSpanT &... args )
inline

◆ int_containing_bit() [1/2]

◆ int_containing_bit() [2/2]

const BitInt * blender::bits::int_containing_bit ( const BitInt * data,
const int64_t bit_index )
inline

Definition at line 76 of file BLI_bit_ref.hh.

References BitToIntIndexShift.

◆ invert()

◆ is_bounded_span()

bool blender::bits::is_bounded_span ( const BitSpan span)
inline

Checks if the span fulfills the requirements for a bounded span. Bounded spans can often be processed more efficiently, because fewer cases have to be considered when aligning multiple such spans.

See comments in the function for the exact requirements.

Don't allow small sized spans to cross BitInt boundaries.

Definition at line 152 of file BLI_bit_span.hh.

References blender::bits::BitSpan::bit_range(), BitsPerInt, blender::bits::BitSpan::size(), and blender::IndexRange::start().

Referenced by blender::bits::BoundedBitSpan::BoundedBitSpan(), blender::bits::BoundedBitSpan::BoundedBitSpan(), blender::bits::BoundedBitSpan::BoundedBitSpan(), blender::bits::MutableBoundedBitSpan::MutableBoundedBitSpan(), blender::bits::MutableBoundedBitSpan::MutableBoundedBitSpan(), blender::bits::MutableBoundedBitSpan::MutableBoundedBitSpan(), blender::bits::tests::TEST(), and try_get_bounded_span().

◆ mask_first_n_bits()

◆ mask_last_n_bits()

BitInt blender::bits::mask_last_n_bits ( const int64_t n)
inline

Definition at line 47 of file BLI_bit_ref.hh.

References BitsPerInt.

Referenced by mask_range_bits(), and blender::bits::tests::TEST().

◆ mask_range_bits()

◆ mask_single_bit()

BitInt blender::bits::mask_single_bit ( const int64_t bit_index)
inline

◆ mix_into_first_expr()

template<typename ExprFn , typename FirstBitSpanT , typename... BitSpanT>
void blender::bits::mix_into_first_expr ( ExprFn && expr,
FirstBitSpanT && first_arg,
const BitSpanT &... args )
inline

◆ operator&=() [1/2]

template<typename... BitSpanT>
void blender::bits::operator&= ( MutableBitSpan first_arg,
const BitSpanT &... args )
inline

Definition at line 241 of file BLI_bit_span_ops.hh.

References inplace_and().

◆ operator&=() [2/2]

template<typename... BitSpanT>
void blender::bits::operator&= ( MutableBoundedBitSpan first_arg,
const BitSpanT &... args )
inline

Definition at line 247 of file BLI_bit_span_ops.hh.

References inplace_and().

◆ operator<<() [1/4]

std::ostream & blender::bits::operator<< ( std::ostream & stream,
const BitRef & bit )

Definition at line 11 of file bit_ref.cc.

◆ operator<<() [2/4]

std::ostream & blender::bits::operator<< ( std::ostream & stream,
const BitSpan & span )

Definition at line 86 of file bit_span.cc.

References blender::bits::BitSpan::size().

◆ operator<<() [3/4]

std::ostream & blender::bits::operator<< ( std::ostream & stream,
const MutableBitRef & bit )

Definition at line 16 of file bit_ref.cc.

◆ operator<<() [4/4]

std::ostream & blender::bits::operator<< ( std::ostream & stream,
const MutableBitSpan & span )

Definition at line 96 of file bit_span.cc.

◆ operator|=() [1/2]

template<typename... BitSpanT>
void blender::bits::operator|= ( MutableBitSpan first_arg,
const BitSpanT &... args )
inline

Definition at line 229 of file BLI_bit_span_ops.hh.

References inplace_or().

◆ operator|=() [2/2]

template<typename... BitSpanT>
void blender::bits::operator|= ( MutableBoundedBitSpan first_arg,
const BitSpanT &... args )
inline

Definition at line 235 of file BLI_bit_span_ops.hh.

References inplace_or().

◆ or_bools_into_bits()

bool blender::bits::or_bools_into_bits ( Span< bool > bools,
MutableBitSpan r_bits,
int64_t allowed_overshoot = 0 )

Converts the bools to bits and ors them into the given bits. For pure conversion, the bits should therefore be zero initialized before they are passed into this function.

Parameters
allowed_overshootHow many bools/bits can be read/written after the end of the given spans. This can help with performance because the internal algorithm can process many elements at once.
Returns
True if any of the checked bools were true (this also includes the bools in the overshoot).

Definition at line 11 of file bit_bool_conversion.cc.

References blender::bits::MutableBitSpan::bit_range(), BitIndexMask, BitsPerInt, BLI_assert, blender::bits::MutableBitSpan::data(), blender::Span< T >::data(), int_containing_bit(), blender::Span< T >::is_empty(), blender::bits::MutableBitSpan::size(), blender::Span< T >::size(), and blender::IndexRange::start().

Referenced by blender::index_mask::IndexMask::from_bools(), and blender::bits::tests::TEST().

◆ spans_equal()

template<typename BitSpanT1 , typename BitSpanT2 >
bool blender::bits::spans_equal ( const BitSpanT1 & a,
const BitSpanT2 & b )
inline

◆ spans_equal_masked()

template<typename BitSpanT1 , typename BitSpanT2 , typename BitSpanT3 >
bool blender::bits::spans_equal_masked ( const BitSpanT1 & a,
const BitSpanT2 & b,
const BitSpanT3 & mask )
inline

◆ to_best_bit_span() [1/3]

template<int64_t InlineBufferCapacity, typename Allocator >
MutableBoundedBitSpan blender::bits::to_best_bit_span ( BitVector< InlineBufferCapacity, Allocator > & data)
inline

Definition at line 395 of file BLI_bit_vector.hh.

References data.

◆ to_best_bit_span() [2/3]

template<int64_t InlineBufferCapacity, typename Allocator >
BoundedBitSpan blender::bits::to_best_bit_span ( const BitVector< InlineBufferCapacity, Allocator > & data)
inline

Definition at line 389 of file BLI_bit_vector.hh.

References data.

◆ to_best_bit_span() [3/3]

template<typename T >
T blender::bits::to_best_bit_span ( const T & data)
inline

Overloaded in BLI_bit_vector.hh. The purpose is to make passing #BitVector into bit span operations more efficient (interpreting it as BoundedBitSpan instead of just BitSpan).

Definition at line 390 of file BLI_bit_span.hh.

References data, and blender::is_same_any_v.

Referenced by any_set_expr(), foreach_1_index_expr(), and mix_into_first_expr().

◆ try_get_bounded_span()

Variable Documentation

◆ all_bounded_spans

template<typename... Args>
bool blender::bits::all_bounded_spans
constexpr
Initial value:
=
(is_same_any_v<std::decay_t<Args>, BoundedBitSpan, MutableBoundedBitSpan> && ...)

Definition at line 401 of file BLI_bit_span.hh.

Referenced by blender::bits::detail::any_set_expr(), blender::bits::detail::foreach_1_index_expr(), and blender::bits::detail::mix_into_first_expr().

◆ BitIndexMask

◆ BitsPerInt

◆ BitToIntIndexShift

int64_t blender::bits::BitToIntIndexShift
staticconstexpr