Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::DynArrayHeap< T, Compare >::Iterator Class Reference

Iterator on the items of the heap, in the order of its array, which is not the sorted one. More...

#include <tpl_dynArrayHeap.H>

Collaboration diagram for Aleph::DynArrayHeap< T, Compare >::Iterator:
[legend]

Public Types

using Set_Type = DynArrayHeap
 The container that it goes through.
 
using Item_Type = T
 The type of the items.
 

Public Member Functions

 Iterator () noexcept=default
 An iterator without a heap, which has no items.
 
 Iterator (const DynArrayHeap &h) noexcept
 Iterator on the first item of a heap, in the order of its array.
 
bool has_curr () const noexcept
 Return true if the iterator is on an item.
 
bool is_last () const noexcept
 Return true if the iterator is on the last item.
 
const T & get_curr_ne () const noexcept
 The current item, without checking that there is one.
 
const T & get_curr () const
 The current item, read-only: the heap order must not be broken.
 
long get_pos () const noexcept
 The position of the current item among those of the heap, from 0.
 
void set_pos (const long pos) noexcept
 Put the iterator on the position pos, without checking it.
 
void next_ne () noexcept
 Move one position forward, without checking.
 
void next ()
 Move one position forward, from the last item to the end too.
 
void prev_ne () noexcept
 Move one position backward, without checking.
 
void prev ()
 Move one position backward, from the first item to before it too.
 
void reset_first () noexcept
 Put the iterator on the first item.
 
void reset_last () noexcept
 Put the iterator on the last item.
 
void end () noexcept
 Put the iterator at the end, after the last item.
 

Private Member Functions

long items () const noexcept
 The number of items of the heap; none without a heap.
 

Private Attributes

const DynArrayHeap * heap_ptr = nullptr
 The heap; none in an iterator built without one.
 
long curr_idx = 0
 The position of the current item, from 0.
 

Detailed Description

template<typename T, class Compare = Aleph::less<T>>
class Aleph::DynArrayHeap< T, Compare >::Iterator

Iterator on the items of the heap, in the order of its array, which is not the sorted one.

The items are read-only: the heap order must not be broken. It goes through the items that the heap has, the entries 1 to size() of its array, whatever the array has beyond them, as traverse() does. An insertion or an extraction moves the items, so that the positions that it gave are no longer theirs.

Definition at line 576 of file tpl_dynArrayHeap.H.

Member Typedef Documentation

◆ Item_Type

template<typename T , class Compare = Aleph::less<T>>
using Aleph::DynArrayHeap< T, Compare >::Iterator::Item_Type = T

The type of the items.

Definition at line 589 of file tpl_dynArrayHeap.H.

◆ Set_Type

template<typename T , class Compare = Aleph::less<T>>
using Aleph::DynArrayHeap< T, Compare >::Iterator::Set_Type = DynArrayHeap

The container that it goes through.

Definition at line 588 of file tpl_dynArrayHeap.H.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynArrayHeap< T, Compare >::Iterator::Iterator ( )
defaultnoexcept

An iterator without a heap, which has no items.

◆ Iterator() [2/2]

template<typename T , class Compare = Aleph::less<T>>
Aleph::DynArrayHeap< T, Compare >::Iterator::Iterator ( const DynArrayHeap &  h)
inlinenoexcept

Iterator on the first item of a heap, in the order of its array.

Parameters
[in]hthe heap.

Definition at line 598 of file tpl_dynArrayHeap.H.

Member Function Documentation

◆ end()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::Iterator::end ( )
inlinenoexcept

Put the iterator at the end, after the last item.

Definition at line 668 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx, and Aleph::DynArrayHeap< T, Compare >::Iterator::items().

Referenced by TEST().

◆ get_curr()

template<typename T , class Compare = Aleph::less<T>>
const T & Aleph::DynArrayHeap< T, Compare >::Iterator::get_curr ( ) const
inline

The current item, read-only: the heap order must not be broken.

Exceptions
std::underflow_errorif the iterator is before the first item.
std::overflow_errorif it is after the last item, or has no heap.

Definition at line 619 of file tpl_dynArrayHeap.H.

References ah_overflow_error_if, ah_underflow_error_if, Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx, Aleph::DynArrayHeap< T, Compare >::Iterator::get_curr_ne(), and Aleph::DynArrayHeap< T, Compare >::Iterator::items().

Referenced by TEST().

◆ get_curr_ne()

template<typename T , class Compare = Aleph::less<T>>
const T & Aleph::DynArrayHeap< T, Compare >::Iterator::get_curr_ne ( ) const
inlinenoexcept

◆ get_pos()

template<typename T , class Compare = Aleph::less<T>>
long Aleph::DynArrayHeap< T, Compare >::Iterator::get_pos ( ) const
inlinenoexcept

The position of the current item among those of the heap, from 0.

Definition at line 627 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx.

◆ has_curr()

template<typename T , class Compare = Aleph::less<T>>
bool Aleph::DynArrayHeap< T, Compare >::Iterator::has_curr ( ) const
inlinenoexcept

◆ is_last()

template<typename T , class Compare = Aleph::less<T>>
bool Aleph::DynArrayHeap< T, Compare >::Iterator::is_last ( ) const
inlinenoexcept

◆ items()

◆ next()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::Iterator::next ( )
inline

Move one position forward, from the last item to the end too.

Exceptions
std::overflow_errorif the iterator is at the end, or has no heap.

Definition at line 640 of file tpl_dynArrayHeap.H.

References ah_overflow_error_if, Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx, Aleph::DynArrayHeap< T, Compare >::Iterator::heap_ptr, Aleph::DynArrayHeap< T, Compare >::Iterator::items(), and Aleph::DynArrayHeap< T, Compare >::Iterator::next_ne().

Referenced by TEST().

◆ next_ne()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::Iterator::next_ne ( )
inlinenoexcept

Move one position forward, without checking.

Definition at line 633 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx.

Referenced by Aleph::DynArrayHeap< T, Compare >::Iterator::next().

◆ prev()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::Iterator::prev ( )
inline

Move one position backward, from the first item to before it too.

Exceptions
std::underflow_errorif the iterator is before the first item.

Definition at line 655 of file tpl_dynArrayHeap.H.

References ah_underflow_error_if, Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx, and Aleph::DynArrayHeap< T, Compare >::Iterator::prev_ne().

◆ prev_ne()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::Iterator::prev_ne ( )
inlinenoexcept

Move one position backward, without checking.

Definition at line 648 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx.

Referenced by Aleph::DynArrayHeap< T, Compare >::Iterator::prev().

◆ reset_first()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::Iterator::reset_first ( )
inlinenoexcept

Put the iterator on the first item.

Definition at line 662 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx.

◆ reset_last()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::Iterator::reset_last ( )
inlinenoexcept

Put the iterator on the last item.

Definition at line 665 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx, and Aleph::DynArrayHeap< T, Compare >::Iterator::items().

Referenced by TEST().

◆ set_pos()

template<typename T , class Compare = Aleph::less<T>>
void Aleph::DynArrayHeap< T, Compare >::Iterator::set_pos ( const long  pos)
inlinenoexcept

Put the iterator on the position pos, without checking it.

Definition at line 630 of file tpl_dynArrayHeap.H.

References Aleph::DynArrayHeap< T, Compare >::Iterator::curr_idx.

Member Data Documentation

◆ curr_idx

◆ heap_ptr

template<typename T , class Compare = Aleph::less<T>>
const DynArrayHeap* Aleph::DynArrayHeap< T, Compare >::Iterator::heap_ptr = nullptr
private

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