PMDK C++ bindings  1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
pmem::obj::slice< Iterator > Class Template Reference

Provides interface to access sequence of objects. More...

#include <libpmemobj++/slice.hpp>

Public Types

using size_type = std::size_t
 
using iterator = Iterator
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using reference = typename std::iterator_traits< iterator >::reference
 

Public Member Functions

 slice (Iterator begin, Iterator end)
 Constructor taking two iterators, which define a range. More...
 
 slice (const slice &other) noexcept=default
 Defaulted copy constructor.
 
sliceoperator= (const slice &other) noexcept=default
 Defaulted assignment operator.
 
iterator begin () const noexcept
 
iterator end () const noexcept
 
reverse_iterator rbegin () const noexcept
 Returns a reverse_iterator to the last element in the range. More...
 
reverse_iterator rend () const noexcept
 Returns a reverse_iterator to the first element in the range. More...
 
reference at (size_type idx)
 Access operator for a single element of slice. More...
 
reference operator[] (size_type idx)
 Subscript operator, providing access to a single element of the slice. More...
 
size_type size () const
 Returns total number of elements within slice's range. More...
 

Detailed Description

template<typename Iterator>
class pmem::obj::slice< Iterator >

Provides interface to access sequence of objects.

It provides the view of any sequence of objects and it simplifies the access to that sequence, with the help of iterators. It's used e.g. in several data structures to deliver range methods. As an example slice usage please see: pmem::obj::vector::range() .

Slice can be used with any iterator type that supports:

  • indexing of elements - operator[],
  • subtraction of two iterators - operator-(),
  • pre-decrementing the iterator - operator--().

Constructor & Destructor Documentation

◆ slice()

template<typename Iterator >
pmem::obj::slice< Iterator >::slice ( Iterator  begin,
Iterator  end 
)
inline

Constructor taking two iterators, which define a range.

Note
These iterators have to support: operator[], operator-(), and operator--()
Exceptions
std::out_of_rangeif it_end < it_begin.

Member Function Documentation

◆ at()

template<typename Iterator >
reference pmem::obj::slice< Iterator >::at ( size_type  idx)
inline

Access operator for a single element of slice.

Parameters
idxindex of selected element.
Exceptions
std::out_of_rangeif idx is greater or equal to size.
Returns
reference to a selected object.

◆ begin()

template<typename Iterator >
iterator pmem::obj::slice< Iterator >::begin ( ) const
inlinenoexcept
Returns
iterator to the beginning of the slice's range.

◆ end()

template<typename Iterator >
iterator pmem::obj::slice< Iterator >::end ( ) const
inlinenoexcept
Returns
iterator to the end of the slice's range.

◆ operator[]()

template<typename Iterator >
reference pmem::obj::slice< Iterator >::operator[] ( size_type  idx)
inline

Subscript operator, providing access to a single element of the slice.

It internally increments from begin iterator,

Parameters
idxpositions forward.
Note
No bounds checking is performed, so the iterator may become invalid.
Returns
reference to a selected object.

◆ rbegin()

template<typename Iterator >
reverse_iterator pmem::obj::slice< Iterator >::rbegin ( ) const
inlinenoexcept

Returns a reverse_iterator to the last element in the range.

Reverse iterators iterate backwards: increasing them moves them towards the beginning of the range.

Returns
reverse_iterator to the reverse beginning of the slice's range.

◆ rend()

template<typename Iterator >
reverse_iterator pmem::obj::slice< Iterator >::rend ( ) const
inlinenoexcept

Returns a reverse_iterator to the first element in the range.

Reverse iterators iterate backwards: increasing them moves them towards the beginning of the range.

Returns
reverse_iterator to the reverse end of the slice's range.

◆ size()

template<typename Iterator >
size_type pmem::obj::slice< Iterator >::size ( ) const
inline

Returns total number of elements within slice's range.

Returns
size_type count of all elements.

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