ORIGINAL
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
original::bitSet< ALLOC > Class Template Referencefinal

A class representing a set of bits, offering functionality to manipulate and query individual bits. More...

#include <bitSet.h>

Inheritance diagram for original::bitSet< ALLOC >:
Inheritance graph
Collaboration diagram for original::bitSet< ALLOC >:
Collaboration graph

Classes

class  Iterator
 An iterator for traversing the bits in a bitSet. More...
 

Public Member Functions

 bitSet (u_integer size, ALLOC allocator=ALLOC{})
 Constructs a bitSet with the given size.
 
 bitSet (const std::initializer_list< bool > &lst)
 Constructs a bitSet from an initializer list.
 
 bitSet (const bitSet &other)
 Copy constructor.
 
bitSetoperator= (const bitSet &other)
 Copy assignment operator.
 
 bitSet (bitSet &&other) noexcept
 Move constructor.
 
bitSetoperator= (bitSet &&other) noexcept
 Move assignment operator.
 
void swap (bitSet &other) noexcept
 Swaps the contents of this bitSet with another.
 
u_integer count () const
 Counts the number of bits set to true.
 
bitSet resize (u_integer new_size) const
 Resizes the bitSet to the given size.
 
u_integer size () const override
 Gets the size of the bitSet.
 
Iteratorbegins () const override
 Gets the iterator to the beginning of the bitSet.
 
Iteratorends () const override
 Gets the iterator to the end of the bitSet.
 
bool get (integer index) const override
 Gets the value of a specific bit by index.
 
booloperator[] (integer index) override
 Gets the reference of a specific bit by index.
 
void set (integer index, const bool &e) override
 Sets the value of a specific bit by index.
 
u_integer indexOf (const bool &e) const override
 Finds the index of the first occurrence of a specific value.
 
bitSetoperator&= (const bitSet &other)
 Performs a bitwise AND operation between two bitSets.
 
bitSetoperator|= (const bitSet &other)
 Performs a bitwise OR operation between two bitSets.
 
bitSetoperator^= (const bitSet &other)
 Performs a bitwise XOR operation between two bitSets.
 
std::string className () const override
 Gets the class name for the bitSet.
 
template<typename Callback = transform<bool>>
void forEach (Callback operation=Callback{})=delete
 Deleted forEach method to prevent misuse.
 
- Public Member Functions inherited from original::serial< TYPE, ALLOC >
virtual TYPE getBegin () const
 Retrieves the first element in the container.
 
virtual TYPE getEnd () const
 Retrieves the last element in the container.
 
virtual TYPE operator[] (integer index) const
 Retrieves the element at the specified index (const version).
 
virtual void set (integer index, const TYPE &e)=0
 Sets the element at the specified index.
 
virtual u_integer indexOf (const TYPE &e) const =0
 Finds the index of the specified element.
 
bool contains (const TYPE &e) const override
 Checks if the container contains the specified element.
 
- Public Member Functions inherited from original::container< TYPE, ALLOC >
bool empty () const
 Checks if the container is empty.
 
virtual ~container ()=default
 Destructor for the container class.
 
- Public Member Functions inherited from original::iterationStream< TYPE, DERIVED >
integer compareTo (const iterationStream &other) const override
 Compares the current iteration stream with another iteration stream.
 
u_integer toHash () const noexcept override
 Computes a hash value for the iteration stream.
 
std::string className () const override
 Returns the class name.
 
std::string toString (bool enter) const override
 Converts the iteration stream to a string representation.
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const chartoCString (bool enter) const
 Direct C-string access with formatting control.
 
template<typename TYPE >
auto formatString (const TYPE &t) -> std::string
 
template<typename TYPE >
auto formatCString (const TYPE &t) -> const char *
 
template<typename TYPE >
auto formatEnum (const TYPE &t) -> std::string
 
template<typename TYPE >
auto formatString (TYPE *const &ptr) -> std::string
 
- Public Member Functions inherited from original::iterable< TYPE >
iterAdaptor begin ()
 Returns an iterator adapter pointing to the beginning of the container.
 
iterAdaptor end ()
 Returns an iterator adapter pointing to the end sentinel of the container.
 
iterAdaptor begin () const
 Returns a const iterator adapter pointing to the beginning of the container.
 
iterAdaptor end () const
 Returns a const iterator adapter pointing to the end sentinel of the container.
 
iterAdaptor first ()
 Returns an iterator adapter pointing to the first element.
 
iterAdaptor last ()
 Returns an iterator adapter pointing to the last element.
 
iterAdaptor first () const
 Returns a const iterator adapter pointing to the first element.
 
iterAdaptor last () const
 Returns a const iterator adapter pointing to the last element.
 
template<typename Callback = transform<TYPE>>
requires Operation<Callback, TYPE>
void forEach (Callback operation=Callback{})
 Applies a given operation to each element in the iterable container.
 
template<typename Callback = transform<TYPE>>
requires Operation<Callback, TYPE>
void forEach (const Callback &operation=Callback{}) const
 Applies a given operation to each element in the iterable container (const version).
 
coroutine::generator< T > generator () const
 Creates a coroutine generator that yields elements from this container.
 
template<typename Callback >
requires original::Operation<Callback, TYPE>
auto forEach (Callback operation) -> void
 
template<typename Callback >
requires original::Operation<Callback, TYPE>
auto forEach (const Callback &operation) const -> void
 
- Public Member Functions inherited from original::comparable< iterationStream< TYPE, DERIVED > >
bool operator== (const iterationStream< TYPE, DERIVED > &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const iterationStream< TYPE, DERIVED > &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const iterationStream< TYPE, DERIVED > &other) const
 Checks if the current object is less than another.
 
bool operator> (const iterationStream< TYPE, DERIVED > &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const iterationStream< TYPE, DERIVED > &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const iterationStream< TYPE, DERIVED > &other) const
 Checks if the current object is greater than or equal to another.
 
virtual ~comparable ()=default
 Virtual destructor for proper cleanup of derived objects.
 
- Public Member Functions inherited from original::hashable< iterationStream< TYPE, DERIVED > >
virtual bool equals (const iterationStream< TYPE, DERIVED > &other) const noexcept
 Compares two objects for equality.
 
virtual ~hashable ()=0
 Virtual destructor.
 

Friends

template<typename ALLOC_ >
bitSet< ALLOC_operator& (const bitSet< ALLOC_ > &lbs, const bitSet< ALLOC_ > &rbs)
 Performs a bitwise AND operation between two bitSets.
 
template<typename ALLOC_ >
bitSet< ALLOC_operator| (const bitSet< ALLOC_ > &lbs, const bitSet< ALLOC_ > &rbs)
 Performs a bitwise OR operation between two bitSets.
 
template<typename ALLOC_ >
bitSet< ALLOC_operator^ (const bitSet< ALLOC_ > &lbs, const bitSet< ALLOC_ > &rbs)
 Performs a bitwise XOR operation between two bitSets.
 
template<typename ALLOC_ >
bitSet< ALLOC_operator~ (const bitSet< ALLOC_ > &bs)
 Performs a bitwise NOT operation on a bitSet.
 

Additional Inherited Members

- Public Types inherited from original::iterable< TYPE >
using T = std::remove_const_t< TYPE >
 
- Static Public Member Functions inherited from original::printable
template<typename TYPE >
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion with type-specific formatting.
 
template<Printable TYPE>
static std::string formatString (const TYPE &t)
 Specialization for types deriving from printable.
 
template<EnumType TYPE>
static std::string formatString (const TYPE &t)
 Specialization for enum types with type-safe formatting.
 
template<typename TYPE >
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting with null safety.
 
template<typename TYPE >
static const charformatCString (const TYPE &t)
 C-string cache for temporary usage with static storage.
 
template<typename TYPE >
static std::string formatEnum (const TYPE &t)
 Enum formatting utility with underlying value extraction.
 
template<>
auto formatString (const char &t) -> std::string
 
template<>
auto formatString (const bool &t) -> std::string
 
template<>
auto formatString (const char *const &ptr) -> std::string
 
- Protected Member Functions inherited from original::serial< TYPE, ALLOC >
bool indexOutOfBound (integer index) const
 Checks if the provided index is out of bounds.
 
integer parseNegIndex (integer index) const
 Converts negative indices into valid positive indices.
 
- Protected Member Functions inherited from original::container< TYPE, ALLOC >
 container (ALLOC alloc=ALLOC{})
 Constructs a container with specified allocator.
 
TYPEallocate (u_integer size)
 Allocates raw memory for elements.
 
void deallocate (TYPE *ptr, u_integer size)
 Deallocates memory previously allocated by allocate()
 
template<typename O_TYPE , typename... Args>
void construct (O_TYPE *o_ptr, Args &&... args)
 Constructs an element in-place.
 
template<typename O_TYPE >
void destroy (O_TYPE *o_ptr)
 Destroys an element.
 
- Protected Member Functions inherited from original::iterationStream< TYPE, DERIVED >
std::string elementsString () const
 Returns a string representation of the elements in the stream.
 
- Protected Attributes inherited from original::container< TYPE, ALLOC >
ALLOC allocator
 The allocator instance used for memory management.
 

Detailed Description

template<typename ALLOC = allocator<bool>>
class original::bitSet< ALLOC >

A class representing a set of bits, offering functionality to manipulate and query individual bits.

Template Parameters
ALLOCAllocator type to use for memory management (default: allocator<bool>)

The bitSet class allows efficient manipulation of individual bits using bitwise operations. It utilizes a dynamic array of 64-bit blocks to store bits and provides methods to access and modify them. Iterators are available for traversing through the bits. Memory management is handled through the specified allocator type.

Constructor & Destructor Documentation

◆ bitSet() [1/4]

template<typename ALLOC >
original::bitSet< ALLOC >::bitSet ( u_integer  size,
ALLOC  allocator = ALLOC{} 
)
explicit

Constructs a bitSet with the given size.

Parameters
sizeThe size of the bitSet.
allocatorAllocator instance to use for memory management

Initializes the bitSet with the specified size, allocating memory blocks using the provided allocator. All bits are initially set to false.

◆ bitSet() [2/4]

template<typename ALLOC >
original::bitSet< ALLOC >::bitSet ( const std::initializer_list< bool > &  lst)

Constructs a bitSet from an initializer list.

Parameters
lstThe initializer list of boolean values.

◆ bitSet() [3/4]

template<typename ALLOC >
original::bitSet< ALLOC >::bitSet ( const bitSet< ALLOC > &  other)

Copy constructor.

Parameters
otherThe bitSet to copy.

Creates a new bitSet by copying the contents of another bitSet. If ALLOC::propagate_on_container_copy_assignment is true, the allocator is also copied.

◆ bitSet() [4/4]

template<typename ALLOC >
original::bitSet< ALLOC >::bitSet ( bitSet< ALLOC > &&  other)
noexcept

Move constructor.

Parameters
otherThe bitSet to move.

Moves the contents of another bitSet into this one, leaving the source in a valid but unspecified state. If ALLOC::propagate_on_container_move_assignment is true, the allocator is also moved.

Member Function Documentation

◆ begins()

template<typename ALLOC >
auto original::bitSet< ALLOC >::begins ( ) const
overridevirtual

Gets the iterator to the beginning of the bitSet.

Returns
An iterator pointing to the beginning.

Implements original::iterable< TYPE >.

◆ className()

template<typename ALLOC >
auto original::bitSet< ALLOC >::className ( ) const
overridevirtual

Gets the class name for the bitSet.

Returns
The class name as a string.

Reimplemented from original::printable.

◆ count()

template<typename ALLOC >
auto original::bitSet< ALLOC >::count ( ) const

Counts the number of bits set to true.

Returns
The count of true bits.

◆ ends()

template<typename ALLOC >
auto original::bitSet< ALLOC >::ends ( ) const
overridevirtual

Gets the iterator to the end of the bitSet.

Returns
An iterator pointing to the end.

Implements original::iterable< TYPE >.

◆ forEach()

template<typename ALLOC = allocator<bool>>
template<typename Callback = transform<bool>>
void original::bitSet< ALLOC >::forEach ( Callback  operation = Callback{})
delete

Deleted forEach method to prevent misuse.

This method is deleted because it doesn't make sense for a bitSet to use the generic forEach with transform callbacks.

◆ get()

template<typename ALLOC >
auto original::bitSet< ALLOC >::get ( integer  index) const
overridevirtual

Gets the value of a specific bit by index.

Parameters
indexThe index of the bit.
Returns
The value of the bit.

Implements original::serial< TYPE, ALLOC >.

◆ indexOf()

template<typename ALLOC >
auto original::bitSet< ALLOC >::indexOf ( const bool e) const
override

Finds the index of the first occurrence of a specific value.

Parameters
eThe value to find.
Returns
The index of the first occurrence.

◆ operator&=()

template<typename ALLOC >
auto original::bitSet< ALLOC >::operator&= ( const bitSet< ALLOC > &  other)

Performs a bitwise AND operation between two bitSets.

Parameters
otherThe bitSet to AND with.
Returns
The result of the AND operation.

◆ operator=() [1/2]

template<typename ALLOC >
auto original::bitSet< ALLOC >::operator= ( bitSet< ALLOC > &&  other)
noexcept

Move assignment operator.

Parameters
otherThe bitSet to move.
Returns
A reference to this bitSet.

Moves the contents of another bitSet into this one, leaving the source in a valid but unspecified state. If ALLOC::propagate_on_container_move_assignment is true, the allocator is also moved.

◆ operator=() [2/2]

template<typename ALLOC >
auto original::bitSet< ALLOC >::operator= ( const bitSet< ALLOC > &  other)

Copy assignment operator.

Parameters
otherThe bitSet to copy.
Returns
A reference to this bitSet.

Copies the contents of another bitSet into this one. If ALLOC::propagate_on_container_copy_assignment is true, the allocator is also copied.

◆ operator[]()

template<typename ALLOC >
auto original::bitSet< ALLOC >::operator[] ( integer  index)
overridevirtual

Gets the reference of a specific bit by index.

Parameters
indexThe index of the bit.
Exceptions
original::unSupportedMethodError

Implements original::serial< TYPE, ALLOC >.

◆ operator^=()

template<typename ALLOC >
auto original::bitSet< ALLOC >::operator^= ( const bitSet< ALLOC > &  other)

Performs a bitwise XOR operation between two bitSets.

Parameters
otherThe bitSet to XOR with.
Returns
The result of the XOR operation.

◆ operator|=()

template<typename ALLOC >
auto original::bitSet< ALLOC >::operator|= ( const bitSet< ALLOC > &  other)

Performs a bitwise OR operation between two bitSets.

Parameters
otherThe bitSet to OR with.
Returns
The result of the OR operation.

◆ resize()

template<typename ALLOC >
auto original::bitSet< ALLOC >::resize ( u_integer  new_size) const

Resizes the bitSet to the given size.

Parameters
new_sizeThe new size for the bitSet.
Returns
A new resized bitSet.

◆ set()

template<typename ALLOC >
auto original::bitSet< ALLOC >::set ( integer  index,
const bool e 
)
override

Sets the value of a specific bit by index.

Parameters
indexThe index of the bit.
eThe value to set the bit to.

◆ size()

template<typename ALLOC >
auto original::bitSet< ALLOC >::size ( ) const
overridevirtual

Gets the size of the bitSet.

Returns
The size of the bitSet.

Implements original::container< TYPE, ALLOC >.

◆ swap()

template<typename ALLOC >
void original::bitSet< ALLOC >::swap ( bitSet< ALLOC > &  other)
noexcept

Swaps the contents of this bitSet with another.

Parameters
otherThe bitSet to swap with.

Exchanges the contents and allocators (if propagate_on_container_swap is true) of this bitSet with another.

Friends And Related Symbol Documentation

◆ operator&

template<typename ALLOC = allocator<bool>>
template<typename ALLOC_ >
bitSet< ALLOC_ > operator& ( const bitSet< ALLOC_ > &  lbs,
const bitSet< ALLOC_ > &  rbs 
)
friend

Performs a bitwise AND operation between two bitSets.

Parameters
lbsThe left bitSet.
rbsThe right bitSet.
Returns
The result of the AND operation.
Template Parameters
ALLOC_Allocator type
Parameters
lbsLeft bitSet
rbsRight bitSet
Returns
Result of bitwise AND operation

◆ operator^

template<typename ALLOC = allocator<bool>>
template<typename ALLOC_ >
bitSet< ALLOC_ > operator^ ( const bitSet< ALLOC_ > &  lbs,
const bitSet< ALLOC_ > &  rbs 
)
friend

Performs a bitwise XOR operation between two bitSets.

Parameters
lbsThe left bitSet.
rbsThe right bitSet.
Returns
The result of the XOR operation.
Template Parameters
ALLOC_Allocator type
Parameters
lbsLeft bitSet
rbsRight bitSet
Returns
Result of bitwise XOR operation

◆ operator|

template<typename ALLOC = allocator<bool>>
template<typename ALLOC_ >
bitSet< ALLOC_ > operator| ( const bitSet< ALLOC_ > &  lbs,
const bitSet< ALLOC_ > &  rbs 
)
friend

Performs a bitwise OR operation between two bitSets.

Parameters
lbsThe left bitSet.
rbsThe right bitSet.
Returns
The result of the OR operation.
Template Parameters
ALLOC_Allocator type
Parameters
lbsLeft bitSet
rbsRight bitSet
Returns
Result of bitwise OR operation

◆ operator~

template<typename ALLOC = allocator<bool>>
template<typename ALLOC_ >
bitSet< ALLOC_ > operator~ ( const bitSet< ALLOC_ > &  bs)
friend

Performs a bitwise NOT operation on a bitSet.

Parameters
bsThe bitSet to negate.
Returns
The result of the NOT operation.
Template Parameters
ALLOC_Allocator type
Parameters
bsbitSet to negate
Returns
Result of bitwise NOT operation

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