ORIGINAL
|
A stream class that allows iteration, comparison, hashing and printing. More...
#include <iterationStream.h>
Public Member Functions | |
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. | |
![]() | |
operator std::string () const | |
Explicit conversion to std::string. | |
operator const char * () const | |
Explicit conversion to C-style string. | |
const char * | toCString (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 |
![]() | |
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. | |
virtual baseIterator< TYPE > * | begins () const =0 |
Returns the iterator to the beginning of the container. | |
virtual baseIterator< TYPE > * | ends () const =0 |
Returns the iterator to the end of the container. | |
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 |
![]() | |
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. | |
![]() | |
virtual bool | equals (const iterationStream< TYPE, DERIVED > &other) const noexcept |
Compares two objects for equality. | |
virtual | ~hashable ()=0 |
Virtual destructor. | |
Protected Member Functions | |
std::string | elementsString () const |
Returns a string representation of the elements in the stream. | |
Additional Inherited Members | |
![]() | |
using | T = std::remove_const_t< TYPE > |
![]() | |
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 char * | formatCString (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 |
A stream class that allows iteration, comparison, hashing and printing.
TYPE | The type of elements contained in the stream. |
DERIVED | The derived class type using CRTP pattern. |
This class provides a unified interface for streams that need to support:
The class uses CRTP to enable static polymorphism, allowing derived classes to inherit common functionality while maintaining their specific type identity.
Provides string conversion capabilities Provides element iteration support Enables stream comparison Provides hash computation
Example usage:
|
overridevirtual |
Returns the class name.
Reimplemented from original::printable.
Reimplemented in original::vector< TYPE, ALLOC >, original::vector< hashNode *, rebind_alloc_pointer >, original::vector< original::hashTable::hashNode *, rebind_alloc_pointer >, original::vector< original::skipList::skipListNode * >, original::vector< priorityTask, allocator< priorityTask > >, and original::vector< TYPE * >.
|
overridevirtual |
Compares the current iteration stream with another iteration stream.
other | Another iteration stream to compare with. |
Performs lexicographical comparison of the two streams:
Implements original::comparable< iterationStream< TYPE, DERIVED > >.
|
protected |
Returns a string representation of the elements in the stream.
This method iterates over all elements and formats them into a comma-separated list enclosed in parentheses. Each element is formatted using formatString function for consistent representation.
Example output: "(element1, element2, element3)"
|
overridevirtualnoexcept |
Computes a hash value for the iteration stream.
Uses hash combination algorithm to create a single hash value from all elements. The hash is computed by iterating through all elements and combining their individual hash values.
Reimplemented from original::hashable< iterationStream< TYPE, DERIVED > >.
|
overridevirtual |
Converts the iteration stream to a string representation.
enter | Whether to add a newline at the end of the string. |
This method returns a string containing the class name followed by a string representation of the stream elements in parentheses. An optional newline character can be appended based on the enter
parameter.
Example output with enter=true: "iterationStream(element1, element2)\n"
Reimplemented from original::printable.