ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::SlotIterator< O, P > Class Template Reference

a bidirectional iterator on the occupied places of the table O, by the policy P with the static functions size( o ), occupied( o , i ) and read( o , i ); the items are constant More...

#include <ADS/Iterators.h>

Public types

using reference = decltype( P::read( std::declval< const O & >() , 0 ) )
 what P::read() gives
using value_type = typename detail::ItemValue< reference >::type
 the items, the pair of the copies for a PairRef
using difference_type = std::ptrdiff_t
 the distances
using iterator_concept = std::bidirectional_iterator_tag
 bidirectional for the concepts of C++20
using iterator_category
 bidirectional for the older algorithms if P::read() gives a reference, input otherwise

Public member functions

 SlotIterator (void)=default
 an iterator on no table
 SlotIterator (const O *o, std::size_t i)
 on the first occupied place from \( i \), or at the end
reference operator* (void) const
 the item of the place, read by P::read()
SlotIterator & operator++ (void)
 to the next occupied place, or to the end \( m \)
SlotIterator & operator-- (void)
 to the previous occupied place
SlotIterator operator++ (int)
 to the next occupied place, returning the iterator before the step
SlotIterator operator-- (int)
 to the previous occupied place, returning the iterator before the step
bool operator== (const SlotIterator &o) const
 equal on the same place
std::size_t place (void) const
 the place

Detailed description

template<class O, class P>
class ADS::SlotIterator< O, P >

a bidirectional iterator on the occupied places of the table O, by the policy P with the static functions size( o ), occupied( o , i ) and read( o , i ); the items are constant

Member typedef documentation

◆ difference_type

template<class O, class P>
using ADS::SlotIterator< O, P >::difference_type = std::ptrdiff_t

the distances

◆ iterator_category

template<class O, class P>
using ADS::SlotIterator< O, P >::iterator_category
Initial value:
std::conditional_t< std::is_reference_v< reference > ,
std::bidirectional_iterator_tag ,
std::input_iterator_tag >

bidirectional for the older algorithms if P::read() gives a reference, input otherwise

◆ iterator_concept

template<class O, class P>
using ADS::SlotIterator< O, P >::iterator_concept = std::bidirectional_iterator_tag

bidirectional for the concepts of C++20

◆ reference

template<class O, class P>
using ADS::SlotIterator< O, P >::reference = decltype( P::read( std::declval< const O & >() , 0 ) )

what P::read() gives

◆ value_type

template<class O, class P>
using ADS::SlotIterator< O, P >::value_type = typename detail::ItemValue< reference >::type

the items, the pair of the copies for a PairRef

Constructor and destructor documentation

◆ SlotIterator() [1/2]

template<class O, class P>
ADS::SlotIterator< O, P >::SlotIterator ( void )
default

an iterator on no table

◆ SlotIterator() [2/2]

template<class O, class P>
ADS::SlotIterator< O, P >::SlotIterator ( const O * o,
std::size_t i )
inline

on the first occupied place from \( i \), or at the end

Member function documentation

◆ operator*()

template<class O, class P>
reference ADS::SlotIterator< O, P >::operator* ( void ) const
inline

the item of the place, read by P::read()

◆ operator++() [1/2]

template<class O, class P>
SlotIterator ADS::SlotIterator< O, P >::operator++ ( int )
inline

to the next occupied place, returning the iterator before the step

◆ operator++() [2/2]

template<class O, class P>
SlotIterator & ADS::SlotIterator< O, P >::operator++ ( void )
inline

to the next occupied place, or to the end \( m \)

In pseudocode (beyond the book), \( i \) the place and \( m \) the size of the table; a whole visit examines each place once:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{next}() \cr 2 & \quad i \gets i + 1 \cr 3 & \quad \textbf{while}\ i < m\ \textbf{and not}\ \mathrm{occupied}( i )\ \textbf{do}\ i \gets i + 1 \end{array}} \]

◆ operator--() [1/2]

template<class O, class P>
SlotIterator ADS::SlotIterator< O, P >::operator-- ( int )
inline

to the previous occupied place, returning the iterator before the step

◆ operator--() [2/2]

template<class O, class P>
SlotIterator & ADS::SlotIterator< O, P >::operator-- ( void )
inline

to the previous occupied place

In pseudocode (beyond the book), the step of operator++() backwards:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{prev}() \cr 2 & \quad \textbf{repeat}\ i \gets i - 1\ \textbf{until} \ \mathrm{occupied}( i ) \end{array}} \]

Precondition
an occupied place precedes the current one

◆ operator==()

template<class O, class P>
bool ADS::SlotIterator< O, P >::operator== ( const SlotIterator< O, P > & o) const
inline

equal on the same place

◆ place()

template<class O, class P>
std::size_t ADS::SlotIterator< O, P >::place ( void ) const
inlinenodiscard

the place


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