proxygen
folly::padded::Iterator< Iter > Class Template Reference

#include <Padded.h>

Inheritance diagram for folly::padded::Iterator< Iter >:

Public Types

typedef std::iterator_traits< Iter >::value_type Node
 

Public Member Functions

 Iterator ()
 
 Iterator (Iter base)
 
const Nodenode () const
 
size_t pos () const
 

Private Types

typedef detail::IteratorBase< Iter >::type Super
 

Private Member Functions

Super::reference dereference () const
 
bool equal (const Iterator &other) const
 
void advance (typename Super::difference_type n)
 
void increment ()
 
void decrement ()
 
Super::difference_type distance_to (const Iterator &other) const
 

Private Attributes

ssize_t pos_
 

Friends

class boost::iterator_core_access
 

Detailed Description

template<class Iter>
class folly::padded::Iterator< Iter >

Wrapper around iterators to Node to return iterators to the underlying node elements.

Definition at line 155 of file Padded.h.

Member Typedef Documentation

template<class Iter >
typedef std::iterator_traits<Iter>::value_type folly::padded::Iterator< Iter >::Node

Definition at line 245 of file Padded.h.

template<class Iter >
typedef detail::IteratorBase<Iter>::type folly::padded::Iterator< Iter >::Super
private

Definition at line 242 of file Padded.h.

Constructor & Destructor Documentation

template<class Iter >
folly::padded::Iterator< Iter >::Iterator ( )
inline

Definition at line 247 of file Padded.h.

247 : pos_(0) {}
template<class Iter >
folly::padded::Iterator< Iter >::Iterator ( Iter  base)
inlineexplicit

Definition at line 249 of file Padded.h.

249 : Super(base), pos_(0) {}
detail::IteratorBase< Iter >::type Super
Definition: Padded.h:242

Member Function Documentation

template<class Iter >
void folly::padded::Iterator< Iter >::advance ( typename Super::difference_type  n)
inlineprivate

Definition at line 269 of file Padded.h.

269  {
270  constexpr ssize_t elementCount = Node::kElementCount; // signed!
271  ssize_t newPos = pos_ + n;
272  if (newPos >= 0 && newPos < elementCount) {
273  pos_ = newPos;
274  return;
275  }
276  ssize_t nblocks = newPos / elementCount;
277  newPos %= elementCount;
278  if (newPos < 0) {
279  --nblocks; // negative
280  newPos += elementCount;
281  }
282  this->base_reference() += nblocks;
283  pos_ = newPos;
284  }
template<class Iter >
void folly::padded::Iterator< Iter >::decrement ( )
inlineprivate

Definition at line 293 of file Padded.h.

293  {
294  if (--pos_ == -1) {
295  --this->base_reference();
296  pos_ = Node::kElementCount - 1;
297  }
298  }
template<class Iter >
Super::reference folly::padded::Iterator< Iter >::dereference ( ) const
inlineprivate

Definition at line 260 of file Padded.h.

260  {
261  return (*this->base_reference()).data()[pos_];
262  }
template<class Iter >
Super::difference_type folly::padded::Iterator< Iter >::distance_to ( const Iterator< Iter > &  other) const
inlineprivate

Definition at line 300 of file Padded.h.

References folly::padded::Iterator< Iter >::pos_.

300  {
301  constexpr ssize_t elementCount = Node::kElementCount; // signed!
302  ssize_t nblocks =
303  std::distance(this->base_reference(), other.base_reference());
304  return nblocks * elementCount + (other.pos_ - pos_);
305  }
template<class Iter >
bool folly::padded::Iterator< Iter >::equal ( const Iterator< Iter > &  other) const
inlineprivate

Definition at line 264 of file Padded.h.

References folly::padded::Iterator< Iter >::pos_.

264  {
265  return (
266  this->base_reference() == other.base_reference() && pos_ == other.pos_);
267  }
template<class Iter >
void folly::padded::Iterator< Iter >::increment ( )
inlineprivate

Definition at line 286 of file Padded.h.

286  {
287  if (++pos_ == Node::kElementCount) {
288  ++this->base_reference();
289  pos_ = 0;
290  }
291  }
template<class Iter >
const Node& folly::padded::Iterator< Iter >::node ( ) const
inline

Definition at line 252 of file Padded.h.

252  {
253  return *this->base_reference();
254  }
template<class Iter >
size_t folly::padded::Iterator< Iter >::pos ( ) const
inline

Definition at line 255 of file Padded.h.

255  {
256  return pos_;
257  }

Friends And Related Function Documentation

template<class Iter >
friend class boost::iterator_core_access
friend

Definition at line 307 of file Padded.h.

Member Data Documentation

template<class Iter >
ssize_t folly::padded::Iterator< Iter >::pos_
private

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