HIBF 1.0.0-rc.1
All Classes Namespaces Files Functions Variables Typedefs Friends Macros Modules Pages Concepts
seqan::hibf::bit_vector Class Reference

An bit vector. More...

#include <hibf/misc/bit_vector.hpp>

+ Inheritance diagram for seqan::hibf::bit_vector:

Public Types

Associated types
using iterator = bit_iterator<false>
 The iterator over the bits.
 
using const_iterator = bit_iterator<true>
 The const iterator over the bits.
 
using value_type = std::iter_value_t<iterator>
 The value type is bool.
 
using reference = std::iter_reference_t<iterator>
 The reference type which is implemented as a proxy.
 
using const_reference = std::iter_reference_t<const_iterator>
 The const reference type which is implemented as a proxy.
 
using size_type = size_t
 The size_type.
 
using difference_type = std::iter_difference_t<iterator>
 The difference type.
 
using allocator_type = allocator_t
 The allocator type to use.
 

Public Member Functions

constexpr chunk_type const * data () const noexcept
 
constexpr chunk_type * data () noexcept
 
template<cereal_archive archive_t>
void load (archive_t &archive)
 Serialisation support function.
 
template<cereal_archive archive_t>
void save (archive_t &archive) const
 Serialisation support function.
 
Constructors, destructor and assignment
constexpr bit_vector (allocator_type const &alloc=allocator_type{})
 The default constructor which optionally sets the allocator.
 
constexpr bit_vector (bit_vector const &)=default
 Default.
 
constexpr bit_vector (bit_vector &&)=default
 Default.
 
constexpr bit_vectoroperator= (bit_vector const &)=default
 Default.
 
constexpr bit_vectoroperator= (bit_vector &&)=default
 Default.
 
constexpr ~bit_vector ()=default
 Default.
 
constexpr bit_vector (size_type const count, bool const bit, allocator_type const &alloc=allocator_type{})
 Constructs the bit vector with count copies of elements with value bit.
 
constexpr bit_vector (std::initializer_list< bool > list, allocator_type const &alloc=allocator_type{})
 Constructs the container initialised with the elements in list.
 
constexpr bit_vector (size_type const count, allocator_type const &alloc=allocator_type{})
 Constructs the container with count default-inserted instances of bool. No copies are made.
 
Member functions
template<std::input_iterator iterator_t, std::sentinel_for< iterator_t > sentinel_t>
requires std::assignable_from<bool &, std::iter_reference_t<iterator_t>>
constexpr void assign (iterator_t first, sentinel_t last)
 Assigns values to the container.
 
constexpr void assign (std::initializer_list< bool > const &ilist)
 Assigns values to the container.
 
constexpr void assign (size_type const count, bool const bit)
 Assigns values to the container.
 
Element access
constexpr reference operator[] (size_type const position) noexcept
 Access specified element.
 
constexpr const_reference operator[] (size_type const position) const noexcept
 Access specified element.
 
constexpr reference back () noexcept
 Access the last element.
 
constexpr const_reference back () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
constexpr bool all () const noexcept
 Checks if all bits are set to true.
 
constexpr bool any () const noexcept
 Checks if any bit is set to true.
 
constexpr bool none () const noexcept
 Checks if none of the bits is set to true.
 
Capacity
constexpr size_type size () const noexcept
 Returns the number of elements.
 
constexpr bool empty () const noexcept
 Checks wether the container is empty.
 
constexpr size_type capacity () const noexcept
 Returns the capacity.
 
constexpr void reserve (size_type const new_capacity)
 Reserves storage.
 
Iterators
constexpr iterator begin () noexcept
 Returns an iterator to the beginning.
 
constexpr const_iterator begin () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
constexpr const_iterator cbegin () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
constexpr iterator end () noexcept
 Returns an iterator to the end.
 
constexpr const_iterator end () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
constexpr const_iterator cend () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
- Public Member Functions inherited from std::vector< uint64_t, std::allocator_traits< seqan::hibf::contrib::aligned_allocator< bool, 64u > >::template rebind_alloc< uint64_t > >
assign (T... args)
 
at (T... args)
 
back (T... args)
 
begin (T... args)
 
capacity (T... args)
 
cbegin (T... args)
 
cend (T... args)
 
clear (T... args)
 
crbegin (T... args)
 
crend (T... args)
 
data (T... args)
 
emplace (T... args)
 
emplace_back (T... args)
 
empty (T... args)
 
end (T... args)
 
erase (T... args)
 
front (T... args)
 
get_allocator (T... args)
 
insert (T... args)
 
max_size (T... args)
 
operator= (T... args)
 
operator[] (T... args)
 
pop_back (T... args)
 
push_back (T... args)
 
rbegin (T... args)
 
rend (T... args)
 
reserve (T... args)
 
resize (T... args)
 
shrink_to_fit (T... args)
 
size (T... args)
 
swap (T... args)
 
vector (T... args)
 
~vector (T... args)
 

Modifiers

constexpr void push_back (bool bit)
 Adds an element to the end.
 
constexpr void resize (size_type const count, bool const bit={})
 Changes the number of elements stored, where additional copies of bit are appended.
 
constexpr void clear () noexcept
 Erases all elements. After this call, size() returns zero. capacity() remains unchanged.
 
constexpr bit_vectoroperator&= (bit_vector const &rhs) noexcept
 Performs binary AND between this and rhs.
 
constexpr bit_vectoroperator|= (bit_vector const &rhs) noexcept
 Performs binary OR between this and rhs.
 
constexpr bit_vectoroperator^= (bit_vector const &rhs) noexcept
 Performs binary XOR between this and rhs.
 
constexpr bit_vector operator~ () const noexcept
 Performs binary NOT.
 
constexpr bit_vectorand_not (bit_vector const &rhs) noexcept
 Computes the bitwise a &= ~b operator without an additional copy.
 
constexpr bit_vectorflip () noexcept
 Flips all bits in-place.
 
constexpr bit_vectorflip (size_type position)
 Flips the bit at the given position.
 
constexpr void swap (bit_vector &other) noexcept
 Exchanges the contents of the container with those of others.
 
constexpr friend bit_vector operator& (bit_vector lhs, bit_vector const &rhs) noexcept
 Performs binary AND.
 
constexpr friend bit_vector operator| (bit_vector lhs, bit_vector const &rhs) noexcept
 Performs binary OR.
 
constexpr friend bit_vector operator^ (bit_vector lhs, bit_vector const &rhs) noexcept
 Performs binary XOR.
 

Detailed Description

An bit vector.

Implements a bit vector on the basis of a std::vector with uint64_t as value type. The bit vector can be dynamically resized and provides additional interfaces to apply efficient bit-operations on it.

The reference type is a special proxy that provides access to a single bit. Note that it is not a real reference but can be converter to a bool or assigned from a bool.

Constructor & Destructor Documentation

◆ bit_vector() [1/3]

constexpr seqan::hibf::bit_vector::bit_vector ( size_type const count,
bool const bit,
allocator_type const & alloc = allocator_type{} )
inlineconstexpr

Constructs the bit vector with count copies of elements with value bit.

Parameters
[in]countThe number of elements to create the bit vector with.
[in]bitThe bit to set during initialisation.
[in]allocThe allocator to use [optional].

◆ bit_vector() [2/3]

constexpr seqan::hibf::bit_vector::bit_vector ( std::initializer_list< bool > list,
allocator_type const & alloc = allocator_type{} )
inlineconstexpr

Constructs the container initialised with the elements in list.

Parameters
[in]listAn initialiser list with the bits set.
[in]allocThe allocator to use [optional].

◆ bit_vector() [3/3]

constexpr seqan::hibf::bit_vector::bit_vector ( size_type const count,
allocator_type const & alloc = allocator_type{} )
inlineconstexpr

Constructs the container with count default-inserted instances of bool. No copies are made.

Parameters
[in]countThe number of elements to create the bit vector with.
[in]allocThe allocator to use [optional].

Member Function Documentation

◆ assign() [1/3]

template<std::input_iterator iterator_t, std::sentinel_for< iterator_t > sentinel_t>
requires std::assignable_from<bool &, std::iter_reference_t<iterator_t>>
constexpr void seqan::hibf::bit_vector::assign ( iterator_t first,
sentinel_t last )
inlineconstexpr

Assigns values to the container.

Template Parameters
iterator_tThe type of the iterator; must model std::input_iterator.
sentinel_tThe type of the sentinel; must model std::sentinel_for iterator_t.
Parameters
[in]firstAn first element to copy elements from.
[in]lastThe end of the range to copy elements from.

Replaces the contents with copies of the range ‘[first, last)’. The behaviour is undefined if either argument is an iterator to *this.

All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.

Exception

If an exception is thrown this function has no effect (strong exception guarantee).

Complexity

Linear in distance between first and last.

◆ assign() [2/3]

constexpr void seqan::hibf::bit_vector::assign ( std::initializer_list< bool > const & ilist)
inlineconstexpr

Assigns values to the container.

Parameters
[in]ilistThe initialiser list with the elements to insert.

Replaces the contents with the elements from the initializer list ilist.

All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.

Exception

If an exception is thrown this function has no effect (strong exception guarantee).

Complexity

Linear in ilist.size().

◆ assign() [3/3]

constexpr void seqan::hibf::bit_vector::assign ( size_type const count,
bool const bit )
inlineconstexpr

Assigns values to the container.

Parameters
[in]countThe new size of the container.
[in]bitThe value to initialize elements of the container with.

Replaces the contents with count copies of value bit.

All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.

Exception

If an exception is thrown this function has no effect (strong exception guarantee).

Complexity

Linear in count.

◆ back()

constexpr reference seqan::hibf::bit_vector::back ( )
inlineconstexprnoexcept

Access the last element.

Returns
A reference to the last element in the container.

Calling back on an empty container causes underfined behaviour.

Exception

Throws nothing.

Complexity

Constant.

◆ reserve()

constexpr void seqan::hibf::bit_vector::reserve ( size_type const new_capacity)
inlineconstexpr

Reserves storage.

Parameters
[in]new_capacityThe new capacity of the bit vector.

Increase the capacity of the vector to a value that's greater or equal to new_capacity. If new_capacity is greater than the current capacity(), new storage is allocated, otherwise the method does nothing. reserve() does not change the size of the vector. If new_capacity is greater than capacity(), all iterators, including the past-the-end iterator, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.

Exceptions

std::length_error if new_capacity > max_size() or any exception thrown by allocator_t::allocate(). If an exception is thrown this function has no effect (strong exception guarantee).

◆ push_back()

constexpr void seqan::hibf::bit_vector::push_back ( bool bit)
inlineconstexpr

Adds an element to the end.

Parameters
bitThe bit to add to the end.

Appends the given element value to the end of the container.

If the new size() is greater than capacity() then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.

Exception

If an exception is thrown (which can be due to allocator_t::allocate(), this function has no effect (strong exception guarantee).

Complexity

Amortised constant.

◆ load()

template<cereal_archive archive_t>
void seqan::hibf::bit_vector::load ( archive_t & archive)
inline

Serialisation support function.

Template Parameters
archive_tType of archive; must satisfy seqan::hibf::cereal_archive.
Parameters
[in]archiveThe archive being serialised from/to.
Attention
These functions are never called directly.

◆ save()

template<cereal_archive archive_t>
void seqan::hibf::bit_vector::save ( archive_t & archive) const
inline

Serialisation support function.

Template Parameters
archive_tType of archive; must satisfy seqan::hibf::cereal_archive.
Parameters
[in]archiveThe archive being serialised from/to.
Attention
These functions are never called directly.

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