xtd 0.2.0
Loading...
Searching...
No Matches
xtd::collections::bit_array Class Reference
Inheritance diagram for xtd::collections::bit_array:
xtd::object xtd::iequatable< bit_array > xtd::iclonable xtd::interface xtd::extensions::equality_operators< bit_array, iequatable< bit_array > > xtd::interface

Definition

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).

class core_export_ bit_array : public xtd::object, public xtd::iequatable<bit_array>, public xtd::collections::generic::icollection<bool>, public xtd::iclonable;
bit_array(xtd::size length) noexcept
Initializes a new instance of the xtd::collections::bit_array class that can hold the specified numbe...
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition iclonable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
#define core_export_
Define shared library export.
Definition core_export.hpp:13
Header
#include <xtd/collections/bit_array>
Namespace
xtd::collections
Library
xtd.core
Examples
The following code example shows how to create and initialize a xtd::collections::bit_array and how to print out its values.
#include <xtd/xtd>
class program {
public:
static auto main() -> void {
// Creates and initializes several bit_arrays.
auto my_ba1 = collections::bit_array(5_z);
auto my_ba2 = collections::bit_array(5_z, false);
auto my_bytes = array {1_u8, 2_u8, 3_u8, 4_u8, 5_u8};
auto my_ba3 = collections::bit_array(my_bytes);
auto my_bools = array {true, false, true, true, false};
auto my_ba4 = collections::bit_array(my_bools);
auto my_ints = array {6, 7, 8, 9, 10};
auto my_ba5 = collections::bit_array(my_ints);
// Displays the properties and values of the bit_arrays.
console::write_line(" count: {0}", my_ba1.count());
console::write_line(" length: {0}", my_ba1.length());
console::write_line(" values:");
print_values(my_ba1, 8);
console::write_line(" count: {0}", my_ba2.count());
console::write_line(" length: {0}", my_ba2.length());
console::write_line(" values:");
print_values(my_ba2, 8);
console::write_line(" count: {0}", my_ba3.count());
console::write_line(" length: {0}", my_ba3.length());
console::write_line(" values:");
print_values(my_ba3, 8);
console::write_line(" count: {0}", my_ba4.count());
console::write_line(" length: {0}", my_ba4.length());
console::write_line(" values:");
print_values(my_ba4, 8);
console::write_line(" count: {0}", my_ba5.count());
console::write_line(" length: {0}", my_ba5.length());
console::write_line(" values:");
print_values(my_ba5, 8);
}
template<class object_t>
static void print_values(const ienumerable<object_t>& my_list, int my_width ) {
auto i = my_width;
for (auto obj : my_list) {
if (i <= 0) {
i = my_width;
}
i--;
console::write("{,8}", obj);
}
}
};
startup_(program::main);
// This code produces the following output :
//
// my_ba1
// count: 5
// length: 5
// values:
// false false false false false
// my_ba2
// count: 5
// length: 5
// values:
// false false false false false
// my_ba3
// count: 40
// length: 40
// values:
// true false false false false false false false
// false true false false false false false false
// true true false false false false false false
// false false true false false false false false
// true false true false false false false false
// my_ba4
// count: 5
// length: 5
// values:
// true false true true false
// my_ba5
// count: 160
// length: 160
// values:
// false true true false false false false false
// false false false false false false false false
// false false false false false false false false
// false false false false false false false false
// true true true false false false false false
// false false false false false false false false
// false false false false false false false false
// false false false false false false false false
// false false false true false false false false
// false false false false false false false false
// false false false false false false false false
// false false false false false false false false
// true false false true false false false false
// false false false false false false false false
// false false false false false false false false
// false false false false false false false false
// false true false true false false false false
// false false false false false false false false
// false false false false false false false false
// false false false false false false false false
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Manages a compact array of bit values, which are represented as booleans, where true indicates that t...
Definition bit_array.hpp:41
static void write(arg_t &&value)
Writes the text representation of the specified value to the standard output stream.
Definition console.hpp:462
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:168
@ i
The I key.
Definition console_key.hpp:104

Public Aliases

using value_type
 Represents the list value 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.
 

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

template<xtd::size length>
auto bits () const noexcept -> std::bitset< length >
 Returns a std::bitset object containing the Booleans contained in the current xtd::collections::bit_array.
 
auto bits () const noexcept -> std::vector< bool >
 Returns a std::vector<bool> object containing the Booleans contained in the current xtd::collections::bit_array.
 
auto count () const noexcept -> xtd::size override
 Gets the number of elements contained in the xtd::collections::bit_array.
 
auto length () const noexcept -> xtd::size
 Gets the number of elements contained in the xtd::collections::bit_array.
 
auto length (xtd::size value) -> void
 Sets the number of elements contained in the xtd::collections::bit_array.
 

Public Methods

auto and_ (const bit_array &value) -> const bit_array &
 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.
 
xtd::uptr< xtd::objectclone () const override
 Creates a new object that is a copy of the current instance.
 
auto copy_to (xtd::array< bool > &array, xtd::size index) const -> void override
 Copies the elements of the xtd::collections::bit_array to an xtd::array, starting at a particular xtd::array index.
 
auto equals (const bit_array &value) const noexcept -> bool 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.
 
auto equals (const object &obj) const noexcept -> bool 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.
 
auto get (xtd::size index) const -> bool
 Gets the value of the bit at a specific position in the xtd::collections::bit_array.
 
auto get (xtd::size index) -> bool &
 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.
 
auto has_all_set () const noexcept -> bool
 Determines whether all bits in the xtd::collections::bit_array are set to true.
 
auto has_any_set () const noexcept -> bool
 Determines whether any bit in the xtd::collections::bit_array is set to true.
 
auto left_shift (xtd::size count) noexcept -> bit_array &
 Shifts all the bit values of the current xtd::collections::bit_array to the left on count bits.
 
auto not_ () -> const bit_array &
 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.
 
auto or_ (const bit_array &value) -> const bit_array &
 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.
 
auto right_shift (xtd::size count) noexcept -> bit_array &
 Shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.
 
auto set (xtd::size index, bool value) -> void
 Sets the value of the bit at a specific position in the xtd::collections::bit_array.
 
auto set_all (bool value) -> void
 Sets all bits in the xtd::collections::bit_array to the specified value.
 
auto to_string () const noexcept -> xtd::string override
 Returns a xtd::string that represents the current object.
 
auto xor_ (const bit_array &value) -> const bit_array &
 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

auto operator[] (xtd::size index) const -> const bool &
 Gets the element at the specified index.
 
auto operator[] (xtd::size index) -> bool &
 Gets or Sets the element at the specified index.
 
auto operator& (const bit_array &value) const -> bit_array
 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.
 
auto operator&= (const bit_array &value) -> bit_array &
 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.
 
auto operator| (const bit_array &value) const -> bit_array
 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.
 
auto operator|= (const bit_array &value) -> bit_array &
 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.
 
auto operator^ (const bit_array &value) const -> bit_array
 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.
 
auto operator^= (const bit_array &value) -> bit_array &
 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.
 
auto operator~ () const -> bit_array
 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.
 
auto operator>> (xtd::size count) const noexcept -> bit_array
 The right shift operator shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.
 
auto operator>>= (xtd::size count) noexcept -> bit_array &
 The right shift operator shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.
 
auto operator<< (xtd::size count) const noexcept -> bit_array
 The left shift operator shifts all the bit values of the current xtd::collections::bit_array to the left on count bits.
 
auto operator<<= (xtd::size count) noexcept -> bit_array &
 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.
 

Member Typedef Documentation

◆ value_type

Represents the list value type.

◆ base_type

Represents the list base type.

◆ size_type

Represents the list size type (usually xtd::size).

◆ difference_type

Represents the list difference type (usually xtd::ptrdiff).

◆ reference

Represents the reference of list value type.

◆ const_reference

Represents the const reference of list value type.

◆ pointer

Represents the pointer of list value type.

◆ const_pointer

Represents the const pointer of list value type.

Constructor & Destructor Documentation

◆ bit_array() [1/8]

xtd::collections::bit_array::bit_array ( xtd::size length)
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.

Parameters
length_The number of bit values in the new xtd::collections::bit_array.
Exceptions
xtd::argument_out_of_range_exceptionlength_ is less than 0.
Remarks
This constructor is an O(n) operation, where n is length_.

◆ bit_array() [2/8]

xtd::collections::bit_array::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.

Parameters
length_The number of bit values in the new xtd::collections::bit_array.
defaultValueThebool value to assign to each bit.
Exceptions
xtd::argument_out_of_range_exceptionlength_ is less than 0.
Remarks
This constructor is an O(n) operation, where n is length_.

◆ bit_array() [3/8]

xtd::collections::bit_array::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.

Parameters
valuesAn array of booleans to copy.
Remarks
This constructor is an O(n) operation, where n is the number of elements in values.

◆ bit_array() [4/8]

xtd::collections::bit_array::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.

Parameters
valuesAn initializer list of booleans to copy.
Remarks
This constructor is an O(n) operation, where n is the number of elements in values.

◆ bit_array() [5/8]

xtd::collections::bit_array::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.

Parameters
valuesAn array of bytes containing the values to copy, where each byte represents eight consecutive bits.
Remarks
The first byte in the array represents bits 0 through 7, the second byte represents bits 8 through 15, and so on. The Least Significant Bit of each byte represents the lowest index value: " bytes [0] & 1" represents bit 0, " bytes [0] & 2" represents bit 1, " bytes [0] & 4" represents bit 2, and so on.
This constructor is an O(n) operation, where n is the number of elements in values.

◆ bit_array() [6/8]

xtd::collections::bit_array::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.

Parameters
valuesAn array of integers containing the values to copy, where each integer represents 32 consecutive bits.
Remarks
The number in the first values array element represents bits 0 through 31, the second number in the array represents bits 32 through 63, and so on. The Least Significant Bit of each integer represents the lowest index value: " values [0] & 1" represents bit 0, " values [0] & 2" represents bit 1, " values [0] & 4" represents bit 2, and so on.
This constructor is an O(n) operation, where n is the number of elements in values.

◆ bit_array() [7/8]

template<xtd::size length>
xtd::collections::bit_array::bit_array ( const std::bitset< length > & bit_set)
inlinenoexcept

Initializes a new instance of the xtd::collections::bit_array class that contains bit values copied from the specified bitset.

Parameters
valuesA std::bitset object that contains bit values.
Remarks
This constructor is an O(n) operation, where n is the number of elements in values.

◆ bit_array() [8/8]

xtd::collections::bit_array::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>.

Parameters
valuesA std::vector<bool> object that contains bit values.
Remarks
This constructor is an O(n) operation, where n is the number of elements in values.

Member Function Documentation

◆ bits() [1/2]

template<xtd::size length>
auto xtd::collections::bit_array::bits ( ) const -> std::bitset<length>
inlinenoexcept

Returns a std::bitset object containing the Booleans contained in the current xtd::collections::bit_array.

Returns
The std::bitset object.

◆ bits() [2/2]

auto xtd::collections::bit_array::bits ( ) const -> std::vector<bool>
inlinenoexcept

Returns a std::vector<bool> object containing the Booleans contained in the current xtd::collections::bit_array.

Returns
The std::vector<bool> object.

◆ count()

auto xtd::collections::bit_array::count ( ) const -> xtd::size
overridenoexcept

Gets the number of elements contained in the xtd::collections::bit_array.

Returns
The number of elements contained in the xtd::collections::bit_array.
Remarks
Retrieving the value of this property is an O(1) operation; setting the property is an O(n) operation, where n is the new capacity.

◆ length() [1/2]

auto xtd::collections::bit_array::length ( ) const -> xtd::size
noexcept

Gets the number of elements contained in the xtd::collections::bit_array.

Returns
The number of elements contained in the xtd::collections::bit_array.
Remarks
xtd::collections::bit_array::length and xtd::collections::bit_array::count return the same value. xtd::collections::bit_array::length can be set to a specific value.

◆ length() [2/2]

auto xtd::collections::bit_array::length ( xtd::size value) -> void

Sets the number of elements contained in the xtd::collections::bit_array.

Parameters
valueThe number of elements contained in the xtd::collections::bit_array.
Remarks
xtd::collections::bit_array::length and xtd::collections::bit_array::count return the same value. xtd::collections::bit_array::length can be set to a specific value.

◆ and_()

auto xtd::collections::bit_array::and_ ( const bit_array & value) -> const bit_array &

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise AND operation.
Returns
The current instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise AND operation returns true if both operands are true, and returns false if one or both operands are false.
This method is an O(n) operation, where n is count.

◆ clone()

xtd::uptr< xtd::object > xtd::collections::bit_array::clone ( ) const
overridevirtual

Creates a new object that is a copy of the current instance.

Returns
A new object that is a copy of this instance.

Implements xtd::iclonable.

◆ copy_to()

auto xtd::collections::bit_array::copy_to ( xtd::array< bool > & array,
xtd::size index ) const -> void
override

Copies the elements of the xtd::collections::bit_array to an xtd::array, starting at a particular xtd::array index.

Parameters
arrayThe 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.
indexThe zero-based index in array at which copying begins;
Returns
Number of elements copied.

◆ equals() [1/2]

auto xtd::collections::bit_array::equals ( const bit_array & value) const -> bool
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.

Parameters
valueThe xtd::collections::bit_array to compare with the current object.
Returns
true if the specified value is equal to the current object. otherwise, false.

◆ equals() [2/2]

auto xtd::collections::bit_array::equals ( const object & obj) const -> bool
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.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

Reimplemented from xtd::object.

◆ get() [1/2]

auto xtd::collections::bit_array::get ( xtd::size index) const -> bool

Gets the value of the bit at a specific position in the xtd::collections::bit_array.

Parameters
indexThe zero-based index of the value to get.
Returns
The value of the bit at position index.
Exceptions
xtd::argument_out_of_range_exceptionindex is less than zero. -or- index is greater than or equal to the number of elements in the xtd::collections::bit_array.
Remarks
This method is an O(1) operation.

◆ get() [2/2]

auto xtd::collections::bit_array::get ( xtd::size index) -> bool &

Gets the value of the bit at a specific position in the xtd::collections::bit_array.

Parameters
indexThe zero-based index of the value to get.
Returns
The value of the bit at position index.
Exceptions
xtd::argument_out_of_range_exceptionindex is less than zero. -or- index is greater than or equal to the number of elements in the xtd::collections::bit_array.
Remarks
This method is an O(1) operation.

◆ get_enumerator()

xtd::collections::generic::enumerator< bool > xtd::collections::bit_array::get_enumerator ( ) const
override

Returns an enumerator that iterates through a collection.

Returns
An xtd::collections::generic::ienumerator object that can be used to iterate through the collection.

◆ has_all_set()

auto xtd::collections::bit_array::has_all_set ( ) const -> bool
noexcept

Determines whether all bits in the xtd::collections::bit_array are set to true.

Returns
true if every bit in the xtd::collections::bit_array is set to true, or if xtd::collections::bit_array is empty; otherwise, false.

◆ has_any_set()

auto xtd::collections::bit_array::has_any_set ( ) const -> bool
noexcept

Determines whether any bit in the xtd::collections::bit_array is set to true.

Returns
true if xtd::collections::bit_array is not empty and at least one of its bit is set to true; otherwise, false.

◆ left_shift()

auto xtd::collections::bit_array::left_shift ( xtd::size count) -> bit_array &
noexcept

Shifts all the bit values of the current xtd::collections::bit_array to the left on count bits.

Parameters
countThe number of shifts to make for each bit.
Returns
The current xtd::collections::bit_array.
Remarks
The current xtd::collections::bit_array is updated and returned.

◆ not_()

auto xtd::collections::bit_array::not_ ( ) -> const bit_array &

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.

Returns
The current instance with inverted bit values.
Remarks
This method is an O(n) operation, where n is count.

◆ or_()

auto xtd::collections::bit_array::or_ ( const bit_array & value) -> const bit_array &

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise OR operation.
Returns
The current instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise OR operation returns true if one or both operands are true, and returns false if both operands are false.
This method is an O(n) operation, where n is count.

◆ right_shift()

auto xtd::collections::bit_array::right_shift ( xtd::size count) -> bit_array &
noexcept

Shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.

Parameters
countThe number of shifts to make for each bit.
Returns
The current xtd::collections::bit_array.
Remarks
The current xtd::collections::bit_array is updated and returned.

◆ set()

auto xtd::collections::bit_array::set ( xtd::size index,
bool value ) -> void

Sets the value of the bit at a specific position in the xtd::collections::bit_array.

Parameters
indexThe zero-based index of the value to get.
valueThe bool value to assign to the bit.
Exceptions
xtd::argument_out_of_range_exceptionindex is less than zero. -or- index is greater than or equal to the number of elements in the xtd::collections::bit_array.
Remarks
This method is an O(1) operation.

◆ set_all()

auto xtd::collections::bit_array::set_all ( bool value) -> void

Sets all bits in the xtd::collections::bit_array to the specified value.

Parameters
valueThe bool value to assign to all bits.
Remarks
This method is an O(n) operation, where n is count.

◆ to_string()

auto xtd::collections::bit_array::to_string ( ) const -> xtd::string
overridevirtualnoexcept

Returns a xtd::string that represents the current object.

Returns
A string that represents the current object.

Reimplemented from xtd::object.

◆ xor_()

auto xtd::collections::bit_array::xor_ ( const bit_array & value) -> const bit_array &

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise exclusive OR operation.
Returns
The current instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise exclusive OR operation returns true if exactly one operand is true, and returns false if both operands have the same bool value.
This method is an O(n) operation, where n is count.

◆ operator[]() [1/2]

auto xtd::collections::bit_array::operator[] ( xtd::size index) const -> const bool &

Gets the element at the specified index.

Parameters
indexThe zero-based index of the element to get.
Returns
The element at the specified index.
Exceptions
xtd::argument_out_of_range_exceptionindex is less than 0 or index is equal to or greater than count.

◆ operator[]() [2/2]

auto xtd::collections::bit_array::operator[] ( xtd::size index) -> bool &

Gets or Sets the element at the specified index.

Parameters
indexThe zero-based index of the element to get.
Returns
The element at the specified index.
Exceptions
xtd::argument_out_of_range_exceptionindex is less than 0 or index is equal to or greater than count.

◆ operator&()

auto xtd::collections::bit_array::operator& ( const bit_array & value) const -> bit_array

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise AND operation.
Returns
The new instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise AND operation returns true if both operands are true, and returns false if one or both operands are false.
This method is an O(n) operation, where n is count.

◆ operator&=()

auto xtd::collections::bit_array::operator&= ( const bit_array & value) -> bit_array &

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise AND operation.
Returns
The current instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise AND operation returns true if both operands are true, and returns false if one or both operands are false.
This method is an O(n) operation, where n is count.

◆ operator|()

auto xtd::collections::bit_array::operator| ( const bit_array & value) const -> bit_array

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise OR operation.
Returns
The new instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise OR operation returns true if one or both operands are true, and returns false if both operands are false.
This method is an O(n) operation, where n is count.

◆ operator|=()

auto xtd::collections::bit_array::operator|= ( const bit_array & value) -> bit_array &

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise OR operation.
Returns
The current instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise OR operation returns true if one or both operands are true, and returns false if both operands are false.
This method is an O(n) operation, where n is count.

◆ operator^()

auto xtd::collections::bit_array::operator^ ( const bit_array & value) const -> bit_array

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise exclusive OR operation.
Returns
The new instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise exclusive OR operation returns true if exactly one operand is true, and returns false if both operands have the same bool value.
This method is an O(n) operation, where n is count.

◆ operator^=()

auto xtd::collections::bit_array::operator^= ( const bit_array & value) -> bit_array &

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.

Parameters
valueThe xtd::collections::bit_array with which to perform the bitwise exclusive OR operation.
Returns
The current instance containing the result of 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.
Exceptions
xtd::argument_exceptionvalue and the current xtd::collections::bit_array do not have the same number of elements.
Remarks
The bitwise exclusive OR operation returns true if exactly one operand is true, and returns false if both operands have the same bool value.
This method is an O(n) operation, where n is count.

◆ operator~()

auto xtd::collections::bit_array::operator~ ( ) const -> bit_array

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.

Returns
The new instance with inverted bit values.
Remarks
This method is an O(n) operation, where n is count.

◆ operator>>()

auto xtd::collections::bit_array::operator>> ( xtd::size count) const -> bit_array
noexcept

The right shift operator shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.

Parameters
countThe number of shifts to make for each bit.
Returns
The new shifted xtd::collections::bit_array.
Remarks
The current xtd::collections::bit_array is not updated.

◆ operator>>=()

auto xtd::collections::bit_array::operator>>= ( xtd::size count) -> bit_array &
noexcept

The right shift operator shifts all the bit values of the current xtd::collections::bit_array to the right on count bits.

Parameters
countThe number of shifts to make for each bit.
Returns
The current xtd::collections::bit_array.
Remarks
The current xtd::collections::bit_array is updated and returned.

◆ operator<<()

auto xtd::collections::bit_array::operator<< ( xtd::size count) const -> bit_array
noexcept

The left shift operator shifts all the bit values of the current xtd::collections::bit_array to the left on count bits.

Parameters
countThe number of shifts to make for each bit.
Returns
The new shifted xtd::collections::bit_array.
Remarks
The current xtd::collections::bit_array is not updated.

◆ operator<<=()

auto xtd::collections::bit_array::operator<<= ( xtd::size count) -> bit_array &
noexcept

The left shift operator shifts all the bit values of the current xtd::collections::bit_array to the left on count bits.

Parameters
countThe number of shifts to make for each bit.
Returns
The current xtd::collections::bit_array.
Remarks
The current xtd::collections::bit_array is updated and returned.

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