45# ifndef FILTER_ITERATOR_H
46# define FILTER_ITERATOR_H
122template <
class Container,
class It,
class Show_Item>
152 catch (
const std::overflow_error &) { }
169 for (;
true; this->It::next())
173 catch (
const std::overflow_error &) { }
189 for (this->It::reset_last();
true; this->It::prev())
193 catch (
const std::underflow_error &) { }
210 for (;
true; this->It::prev())
214 catch (
const std::underflow_error &) { }
405 this->It::reset_first();
463 template <
typename Op>
481 template <
typename Pred>
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Generic filter iterator wrapper.
void set_cookie(void *__cookie) noexcept
Sets the cookie pointer.
void next()
Advances the iterator to the next filtered element.
void prev_ne() noexcept
Moves the iterator backward (noexcept version).
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
const Container & get_container() const
Returns a const reference to the container being iterated over.
Filter_Iterator(const Container &c, Show_Item si=Show_Item())
Constructs a filter iterator over a container.
It & get_iterator() noexcept
Returns a reference to the underlying base iterator.
void reset_last()
Resets the iterator to the last filtered element.
Filter_Iterator(const Container &c, void *__cookie, Show_Item si=Show_Item())
Constructs a filter iterator with a cookie.
const It & get_iterator() const noexcept
Returns a const reference to the underlying base iterator.
It Iterator_Type
The type of the base iterator.
Show_Item Filter_Type
The type of the filter functor.
void prev()
Moves the iterator backward to the previous filtered element.
typename It::Item_Type Item_Type
The type of element returned by get_curr()
Filter_Iterator(Show_Item si=Show_Item()) noexcept
Default constructor.
const Container * container_ptr
void * get_cookie() const noexcept
Gets the cookie pointer.
bool empty()
Check if there are no elements that pass the filter.
size_t count()
Count the number of elements that pass the filter.
void backward()
Move backward to the previous element that passes the filter.
void * cookie
User-defined pointer for extensibility (e.g., passing context data to filter)
void reset_first()
Resets the iterator to the first filtered element.
bool has_container() const noexcept
Check if a container has been set.
void forward()
Move forward to the next element that passes the filter.
void set_filter(Show_Item si)
Sets a new filter functor.
void goto_first_valid_item()
Advance to the first element that passes the filter.
const Show_Item & get_filter() const noexcept
Returns a const reference to the filter functor.
void for_each(Op op)
Apply a function to all filtered elements.
bool find_if(Pred pred)
Find the first element that satisfies an additional predicate.
Show_Item & get_filter() noexcept
Returns a reference to the filter functor.
void goto_last_valid_item()
Move to the last element that passes the filter.
Freq_Node * pred
Predecessor node in level-order traversal.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
auto get_curr() const
Return the current tuple (bounds-checked).
bool has_curr() const noexcept
Return true if all underlying iterators are positioned on a valid item.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Default filter functor that shows all elements.
bool operator()(const T &) const noexcept
Always returns true (shows all elements).
Filter functor that hides all elements.
bool operator()(const T &) const noexcept
Always returns false (hides all elements).