openMSX
Public Types | Public Member Functions | Friends | List of all members
cb_iterator< BUF, T > Class Template Reference

This code is heavily based on boost circular_buffer: http://www.boost.org/doc/libs/1_55_0/doc/html/circular_buffer.html The interface of this version and the original boost version is (as much as possible identical). More...

#include <circular_buffer.hh>

Public Types

using value_type = T
 
using pointer = T *
 
using reference = T &
 
using difference_type = ptrdiff_t
 
using iterator_category = std::random_access_iterator_tag
 

Public Member Functions

 cb_iterator ()=default
 
 cb_iterator (const cb_iterator &it)=default
 
 cb_iterator (const BUF *buf_, T *p_)
 
cb_iteratoroperator= (const cb_iterator &it)=default
 
T & operator* () const
 
T * operator-> () const
 
cb_iteratoroperator++ ()
 
cb_iteratoroperator-- ()
 
cb_iterator operator++ (int)
 
cb_iterator operator-- (int)
 
cb_iteratoroperator+= (difference_type n)
 
cb_iteratoroperator-= (difference_type n)
 
T & operator[] (difference_type n) const
 
bool operator== (const cb_iterator &it) const
 
auto operator<=> (const cb_iterator &it) const
 

Friends

difference_type operator- (const cb_iterator &l, const cb_iterator &r)
 
cb_iterator operator+ (cb_iterator it, difference_type n)
 
cb_iterator operator+ (difference_type n, cb_iterator it)
 
cb_iterator operator- (cb_iterator it, difference_type n)
 

Detailed Description

template<typename BUF, typename T>
class cb_iterator< BUF, T >

This code is heavily based on boost circular_buffer: http://www.boost.org/doc/libs/1_55_0/doc/html/circular_buffer.html The interface of this version and the original boost version is (as much as possible identical).

I did leave out some of the more fancy methods like insert/remove in the middle of the buffer or linearize the buffer. If we ever need those we can add them of course. So (for now) this class represents a dynamically sized circular buffer with (efficient) {push,pop}_{front,back} and operator[] methods. It also offers random access iterators. For much more details check the boost documentation. Random access iterator for circular_buffer.

Definition at line 23 of file circular_buffer.hh.

Member Typedef Documentation

◆ difference_type

template<typename BUF , typename T >
using cb_iterator< BUF, T >::difference_type = ptrdiff_t

Definition at line 29 of file circular_buffer.hh.

◆ iterator_category

template<typename BUF , typename T >
using cb_iterator< BUF, T >::iterator_category = std::random_access_iterator_tag

Definition at line 30 of file circular_buffer.hh.

◆ pointer

template<typename BUF , typename T >
using cb_iterator< BUF, T >::pointer = T*

Definition at line 27 of file circular_buffer.hh.

◆ reference

template<typename BUF , typename T >
using cb_iterator< BUF, T >::reference = T&

Definition at line 28 of file circular_buffer.hh.

◆ value_type

template<typename BUF , typename T >
using cb_iterator< BUF, T >::value_type = T

Definition at line 26 of file circular_buffer.hh.

Constructor & Destructor Documentation

◆ cb_iterator() [1/3]

template<typename BUF , typename T >
cb_iterator< BUF, T >::cb_iterator ( )
default

◆ cb_iterator() [2/3]

template<typename BUF , typename T >
cb_iterator< BUF, T >::cb_iterator ( const cb_iterator< BUF, T > &  it)
default

◆ cb_iterator() [3/3]

template<typename BUF , typename T >
cb_iterator< BUF, T >::cb_iterator ( const BUF *  buf_,
T *  p_ 
)
inline

Definition at line 34 of file circular_buffer.hh.

Member Function Documentation

◆ operator*()

template<typename BUF , typename T >
T & cb_iterator< BUF, T >::operator* ( ) const
inline

Definition at line 38 of file circular_buffer.hh.

◆ operator++() [1/2]

template<typename BUF , typename T >
cb_iterator & cb_iterator< BUF, T >::operator++ ( )
inline

Definition at line 45 of file circular_buffer.hh.

◆ operator++() [2/2]

template<typename BUF , typename T >
cb_iterator cb_iterator< BUF, T >::operator++ ( int  )
inline

Definition at line 55 of file circular_buffer.hh.

◆ operator+=()

template<typename BUF , typename T >
cb_iterator & cb_iterator< BUF, T >::operator+= ( difference_type  n)
inline

Definition at line 58 of file circular_buffer.hh.

◆ operator--() [1/2]

template<typename BUF , typename T >
cb_iterator & cb_iterator< BUF, T >::operator-- ( )
inline

Definition at line 50 of file circular_buffer.hh.

◆ operator--() [2/2]

template<typename BUF , typename T >
cb_iterator cb_iterator< BUF, T >::operator-- ( int  )
inline

Definition at line 56 of file circular_buffer.hh.

◆ operator-=()

template<typename BUF , typename T >
cb_iterator & cb_iterator< BUF, T >::operator-= ( difference_type  n)
inline

Definition at line 70 of file circular_buffer.hh.

◆ operator->()

template<typename BUF , typename T >
T * cb_iterator< BUF, T >::operator-> ( ) const
inline

Definition at line 39 of file circular_buffer.hh.

◆ operator<=>()

template<typename BUF , typename T >
auto cb_iterator< BUF, T >::operator<=> ( const cb_iterator< BUF, T > &  it) const
inline

Definition at line 79 of file circular_buffer.hh.

◆ operator=()

template<typename BUF , typename T >
cb_iterator & cb_iterator< BUF, T >::operator= ( const cb_iterator< BUF, T > &  it)
default

◆ operator==()

template<typename BUF , typename T >
bool cb_iterator< BUF, T >::operator== ( const cb_iterator< BUF, T > &  it) const
inline

Definition at line 78 of file circular_buffer.hh.

◆ operator[]()

template<typename BUF , typename T >
T & cb_iterator< BUF, T >::operator[] ( difference_type  n) const
inline

Definition at line 76 of file circular_buffer.hh.

Friends And Related Symbol Documentation

◆ operator+ [1/2]

template<typename BUF , typename T >
cb_iterator operator+ ( cb_iterator< BUF, T >  it,
difference_type  n 
)
friend

Definition at line 72 of file circular_buffer.hh.

◆ operator+ [2/2]

template<typename BUF , typename T >
cb_iterator operator+ ( difference_type  n,
cb_iterator< BUF, T >  it 
)
friend

Definition at line 73 of file circular_buffer.hh.

◆ operator- [1/2]

template<typename BUF , typename T >
cb_iterator operator- ( cb_iterator< BUF, T >  it,
difference_type  n 
)
friend

Definition at line 74 of file circular_buffer.hh.

◆ operator- [2/2]

template<typename BUF , typename T >
difference_type operator- ( const cb_iterator< BUF, T > &  l,
const cb_iterator< BUF, T > &  r 
)
friend

Definition at line 41 of file circular_buffer.hh.


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