Manages a compact array of bit values, which are represented as booleans, where true
indicates that the bit is on (1) and false
indicates the bit is off (0).
Public Aliases | |
using | value_type |
Represents the list value type. | |
using | allocator_type |
Represents the list allocator type. | |
using | base_type |
Represents the list base type. | |
using | size_type |
Represents the list size type (usually xtd::size). | |
using | difference_type |
Represents the list difference type (usually xtd::ptrdiff). | |
using | reference |
Represents the reference of list value type. | |
using | const_reference |
Represents the const reference of list value type. | |
using | pointer |
Represents the pointer of list value type. | |
using | const_pointer |
Represents the const pointer of list value type. | |
using | iterator |
Represents the iterator of list value type. | |
using | const_iterator |
Represents the const iterator of list value type. | |
Public Constructors | |
bit_array (xtd::size length) noexcept | |
Initializes a new instance of the xtd::collections::bit_array class that can hold the specified number of bit values, which are initially set to false . | |
bit_array (xtd::size length, bool defaultValue) noexcept | |
Initializes a new instance of the xtd::collections::bit_array class that can hold the specified number of bit values, which are initially set to the specified value. | |
bit_array (std::initializer_list< bool > il) noexcept | |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified initializer list of booleans. | |
bit_array (const xtd::array< bool > &values) noexcept | |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified array of booleans. | |
bit_array (const xtd::array< xtd::byte > &values) noexcept | |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified array of bytes. | |
bit_array (const xtd::array< int32 > &values) noexcept | |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified array of 32-bit integers. | |
template<xtd::size length> | |
bit_array (const std::bitset< length > &bit_set) noexcept | |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified bitset. | |
bit_array (const std::vector< bool > &booleans) noexcept | |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified std::vector<bool>. | |
Public Properties | |
const_iterator | begin () const noexcept override |
Returns an iterator to the first element of the enumarable. | |
iterator | begin () noexcept override |
Returns an iterator to the first element of the enumarable. | |
template<xtd::size length> | |
std::bitset< length > | bits () const noexcept |
Returns a std::bitset object containing the Booleans contained in the current xtd::collections::bit_array. | |
std::vector< bool > | bits () const noexcept |
Returns a std::vector<bool> object containing the Booleans contained in the current xtd::collections::bit_array. | |
const_iterator | cbegin () const noexcept override |
Returns an iterator to the first element of the enumarable. | |
const_iterator | cend () const noexcept override |
Returns an iterator to the element following the last element of the enumarable. | |
xtd::size | count () const noexcept override |
Gets the number of elements contained in the xtd::collections::bit_array. | |
virtual bool | empty () const noexcept |
Checks if the container has no elements, i.e. whether xtd::collections::bit_array::begin() == xtd::collections::bit_array::end(). | |
const_iterator | end () const noexcept override |
Returns an iterator to the element following the last element of the enumarable. | |
iterator | end () noexcept override |
Returns an iterator to the element following the last element of the enumarable. | |
xtd::size | length () const noexcept |
Gets the number of elements contained in the xtd::collections::bit_array. | |
void | length (xtd::size value) |
Sets the number of elements contained in the xtd::collections::bit_array. | |
bool | is_read_only () const noexcept override |
Gets a value indicating whether the xtd::collections::bit_array is read-only. | |
bool | is_synchronized () const noexcept override |
Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe). | |
const object & | sync_root () const noexcept override |
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>. | |
Public Methods | |
const bit_array & | and_ (const bit_array &value) |
Performs the bitwise AND operation on the elements in the current xtd::collections::bit_array against the corresponding elements in the specified xtd::collections::bit_array. | |
bool | at (xtd::size index) const |
Gets the value of the bit at a specific position in the xtd::collections::bit_array. | |
bool & | at (xtd::size index) |
Gets the value of the bit at a specific position in the xtd::collections::bit_array. | |
xtd::uptr< xtd::object > | clone () const override |
Creates a new object that is a copy of the current instance. | |
void | copy_to (xtd::array< bool > &array, xtd::size index) const override |
Copies the elements of the xtd::collections::bit_array to an xtd::array, starting at a particular xtd::array index. | |
bool | equals (const bit_array &value) const noexcept override |
Determines whether this instance of xtd::collections::bit_array and a specified object, which must also be a xtd::collections::bit_array object, have the same value. | |
bool | equals (const object &obj) const noexcept override |
Determines whether this instance of xtd::collections::bit_array and a specified object, which must also be a xtd::collections::bit_array object, have the same value. | |
bool | get (xtd::size index) const |
Gets the value of the bit at a specific position in the xtd::collections::bit_array. | |
bool & | get (xtd::size index) |
Gets the value of the bit at a specific position in the xtd::collections::bit_array. | |
xtd::collections::generic::enumerator< bool > | get_enumerator () const override |
Returns an enumerator that iterates through a collection. | |
bool | has_all_set () const noexcept |
Determines whether all bits in the xtd::collections::bit_array are set to true . | |
bool | has_any_set () const noexcept |
Determines whether any bit in the xtd::collections::bit_array is set to true . | |
bit_array & | left_shift (xtd::size count) noexcept |
Shifts all the bit values of the current xtd::collections::bit_array to the left on count bits. | |
const bit_array & | not_ () |
Inverts all the bit values in the current xtd::collections::bit_array, so that elements set to true are changed to false , and elements set to false are changed to true . | |
const bit_array & | or_ (const bit_array &value) |
Performs the bitwise OR operation on the elements in the current xtd::collections::bit_array against the corresponding elements in the specified xtd::collections::bit_array. | |
bit_array & | right_shift (xtd::size count) noexcept |
Shifts all the bit values of the current xtd::collections::bit_array to the right on count bits. | |
void | set (xtd::size index, bool value) |
Sets the value of the bit at a specific position in the xtd::collections::bit_array. | |
void | set_all (bool value) |
Sets all bits in the xtd::collections::bit_array to the specified value. | |
xtd::string | to_string () const noexcept override |
Returns a xtd::string that represents the current object. | |
const bit_array & | xor_ (const bit_array &value) |
Performs the bitwise exclusive OR operation on the elements in the current xtd::collections::bit_array against the corresponding elements in the specified xtd::collections::bit_array. | |
Public Operators | |
const bool & | operator[] (xtd::size index) const |
Gets the element at the specified index. | |
bool & | operator[] (xtd::size index) |
Gets or Sets the element at the specified index. | |
bit_array | operator>> (xtd::size count) const noexcept |
The right shift operator shifts all the bit values of the current xtd::collections::bit_array to the right on count bits. | |
bit_array & | operator>>= (xtd::size count) noexcept |
The right shift operator shifts all the bit values of the current xtd::collections::bit_array to the right on count bits. | |
bit_array | operator<< (xtd::size count) const noexcept |
The left shift operator shifts all the bit values of the current xtd::collections::bit_array to the left on count bits. | |
bit_array & | operator<<= (xtd::size count) noexcept |
The left shift operator shifts all the bit values of the current xtd::collections::bit_array to the left on count bits. | |
Additional Inherited Members | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual xtd::size | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<class object_t> | |
xtd::unique_ptr_object< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
virtual bool | equals (const bit_array &) const noexcept=0 |
Indicates whether the current object is equal to another object of the same type. | |
template<class object_a_t, class object_b_t> | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<class object_a_t, class object_b_t> | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
Represents the list value type.
Represents the list allocator type.
Represents the list base type.
Represents the list size type (usually xtd::size).
Represents the list difference type (usually xtd::ptrdiff).
Represents the reference of list value type.
Represents the const reference of list value type.
Represents the pointer of list value type.
Represents the const pointer of list value type.
Represents the iterator of list value type.
Represents the const iterator of list value type.
|
explicitnoexcept |
Initializes a new instance of the xtd::collections::bit_array class that can hold the specified number of bit values, which are initially set to false
.
length_ | The number of bit values in the new xtd::collections::bit_array. |
xtd::argument_out_of_range_exception | length_ is less than 0. |
|
noexcept |
Initializes a new instance of the xtd::collections::bit_array class that can hold the specified number of bit values, which are initially set to the specified value.
length_ | The number of bit values in the new xtd::collections::bit_array. |
defaultValueThe | bool value to assign to each bit. |
xtd::argument_out_of_range_exception | length_ is less than 0. |
|
noexcept |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified initializer list of booleans.
values | An array of booleans to copy. |
|
noexcept |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified array of booleans.
values | An initializer list of booleans to copy. |
|
noexcept |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified array of bytes.
values | An array of bytes containing the values to copy, where each byte represents eight consecutive bits. |
|
noexcept |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified array of 32-bit integers.
values | An array of integers containing the values to copy, where each integer represents 32 consecutive bits. |
|
inlinenoexcept |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified bitset.
values | A std::bitset object that contains bit values. |
|
noexcept |
Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified std::vector<bool>.
values | A std::vector<bool> object that contains bit values. |
|
inlineoverridenoexcept |
Returns an iterator to the first element of the enumarable.
|
inlineoverridenoexcept |
Returns an iterator to the first element of the enumarable.
|
inlinenoexcept |
Returns a std::bitset object containing the Booleans contained in the current xtd::collections::bit_array.
|
inlinenoexcept |
Returns a std::vector<bool> object containing the Booleans contained in the current xtd::collections::bit_array.
|
inlineoverridenoexcept |
Returns an iterator to the first element of the enumarable.
|
inlineoverridenoexcept |
Returns an iterator to the element following the last element of the enumarable.
|
overridenoexcept |
Gets the number of elements contained in the xtd::collections::bit_array.
|
inlinevirtualnoexcept |
Checks if the container has no elements, i.e. whether xtd::collections::bit_array::begin() == xtd::collections::bit_array::end().
true
if the container is empty, false
otherwise.
|
inlineoverridenoexcept |
Returns an iterator to the element following the last element of the enumarable.
|
inlineoverridenoexcept |
Returns an iterator to the element following the last element of the enumarable.
|
noexcept |
Gets the number of elements contained in the xtd::collections::bit_array.
void xtd::collections::bit_array::length | ( | xtd::size | value | ) |
Sets the number of elements contained in the xtd::collections::bit_array.
value | The number of elements contained in the xtd::collections::bit_array. |
|
overridenoexcept |
Gets a value indicating whether the xtd::collections::bit_array is read-only.
true
if the xtd::collections::bit_array is read-only; otherwise, false
. true
, even though individual array elements can be modified.
|
overridenoexcept |
Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe).
true
if access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe); otherwise, false
. synchronized
method, which provides a synchronized wrapper around the underlying collection.
|
overridenoexcept |
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.
sync_root
property. synchronized
method, which provides a synchronized wrapper around the underlying collection. However, derived classes can provide their own synchronized version of the collection using the xtd::collections::generic::icollection::sync_root property. The synchronizing code must perform operations on the xtd::collections::generic::icollection::sync_root property of the collection, not directly on the collection. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the collection instance. synchronized
method on a collection, the expected usage for the xtd::collections::generic::icollection::sync_root looks as follows: Performs the bitwise AND operation on the elements in the current xtd::collections::bit_array against the corresponding elements in the specified xtd::collections::bit_array.
value | The xtd::collections::bit_array with which to perform the bitwise AND operation. |
xtd::argument_exception | value and the current xtd::collections::bit_array do not have the same number of elements. |
true
if both operands are true
, and returns false
if one or both operands are false
. bool xtd::collections::bit_array::at | ( | xtd::size | index | ) | const |
Gets the value of the bit at a specific position in the xtd::collections::bit_array.
index | The zero-based index of the value to get. |
xtd::argument_out_of_range_exception | index is less than zero. -or- index is greater than or equal to the number of elements in the xtd::collections::bit_array. |
bool & xtd::collections::bit_array::at | ( | xtd::size | index | ) |
Gets the value of the bit at a specific position in the xtd::collections::bit_array.
index | The zero-based index of the value to get. |
xtd::argument_out_of_range_exception | index is less than zero. -or- index is greater than or equal to the number of elements in the xtd::collections::bit_array. |
|
overridevirtual |
Creates a new object that is a copy of the current instance.
Implements xtd::iclonable.
|
override |
Copies the elements of the xtd::collections::bit_array to an xtd::array, starting at a particular xtd::array index.
array | The one-dimensional xtd::array that is the destination of the elements copied from xtd::collections::bit_array. The xtd::array must have zero-based indexing. |
index | The zero-based index in array at which copying begins; |
|
overridenoexcept |
Determines whether this instance of xtd::collections::bit_array and a specified object, which must also be a xtd::collections::bit_array object, have the same value.
value | The xtd::collections::bit_array to compare with the current object. |
true
if the specified value is equal to the current object. otherwise, false
.
|
overridevirtualnoexcept |
Determines whether this instance of xtd::collections::bit_array and a specified object, which must also be a xtd::collections::bit_array object, have the same value.
obj | The object to compare with the current object. |
true
if the specified object is equal to the current object. otherwise, false
. Reimplemented from xtd::object.
bool xtd::collections::bit_array::get | ( | xtd::size | index | ) | const |
Gets the value of the bit at a specific position in the xtd::collections::bit_array.
index | The zero-based index of the value to get. |
xtd::argument_out_of_range_exception | index is less than zero. -or- index is greater than or equal to the number of elements in the xtd::collections::bit_array. |
bool & xtd::collections::bit_array::get | ( | xtd::size | index | ) |
Gets the value of the bit at a specific position in the xtd::collections::bit_array.
index | The zero-based index of the value to get. |
xtd::argument_out_of_range_exception | index is less than zero. -or- index is greater than or equal to the number of elements in the xtd::collections::bit_array. |
|
override |
Returns an enumerator that iterates through a collection.
|
noexcept |
Determines whether all bits in the xtd::collections::bit_array are set to true
.
true
if every bit in the xtd::collections::bit_array is set to true, or if xtd::collections::bit_array is empty; otherwise, false
.
|
noexcept |
Determines whether any bit in the xtd::collections::bit_array is set to true
.
true
if xtd::collections::bit_array is not empty and at least one of its bit is set to true
; otherwise, false
. Shifts all the bit values of the current xtd::collections::bit_array to the left on count bits.
count | The number of shifts to make for each bit. |
const bit_array & xtd::collections::bit_array::not_ | ( | ) |
Inverts all the bit values in the current xtd::collections::bit_array, so that elements set to true
are changed to false
, and elements set to false
are changed to true
.
Performs the bitwise OR operation on the elements in the current xtd::collections::bit_array against the corresponding elements in the specified xtd::collections::bit_array.
value | The xtd::collections::bit_array with which to perform the bitwise OR operation. |
xtd::argument_exception | value and the current xtd::collections::bit_array do not have the same number of elements. |
true
if one or both operands are true
, and returns false
if both operands are false
. Shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.
count | The number of shifts to make for each bit. |
void xtd::collections::bit_array::set | ( | xtd::size | index, |
bool | value ) |
Sets the value of the bit at a specific position in the xtd::collections::bit_array.
index | The zero-based index of the value to get. |
value | The bool value to assign to the bit. |
xtd::argument_out_of_range_exception | index is less than zero. -or- index is greater than or equal to the number of elements in the xtd::collections::bit_array. |
void xtd::collections::bit_array::set_all | ( | bool | value | ) |
Sets all bits in the xtd::collections::bit_array to the specified value.
value | The bool value to assign to all bits. |
|
overridevirtualnoexcept |
Returns a xtd::string that represents the current object.
Reimplemented from xtd::object.
Performs the bitwise exclusive OR operation on the elements in the current xtd::collections::bit_array against the corresponding elements in the specified xtd::collections::bit_array.
value | The xtd::collections::bit_array with which to perform the bitwise exclusive OR operation. |
xtd::argument_exception | value and the current xtd::collections::bit_array do not have the same number of elements. |
true
if exactly one operand is true
, and returns false
if both operands have the same bool value. const bool & xtd::collections::bit_array::operator[] | ( | xtd::size | index | ) | const |
Gets the element at the specified index.
index | The zero-based index of the element to get. |
xtd::argument_out_of_range_exception | index is less than 0 or index is equal to or greater than count. |
bool & xtd::collections::bit_array::operator[] | ( | xtd::size | index | ) |
Gets or Sets the element at the specified index.
index | The zero-based index of the element to get. |
xtd::argument_out_of_range_exception | index is less than 0 or index is equal to or greater than count. |
The right shift operator shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.
count | The number of shifts to make for each bit. |
The right shift operator shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.
count | The number of shifts to make for each bit. |
The left shift operator shifts all the bit values of the current xtd::collections::bit_array to the left on count bits.
count | The number of shifts to make for each bit. |
The left shift operator shifts all the bit values of the current xtd::collections::bit_array to the left on count bits.
count | The number of shifts to make for each bit. |