Lunchbox  1.17.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
lfVectorIterator.h
1 
2 /* Copyright (c) 2011-2013, EPFL/Blue Brain Project
3  * Stefan Eilemann <stefan.eilemann@epfl.ch>
4  *
5  * This file is part of Lunchbox <https://github.com/Eyescale/Lunchbox>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 3.0 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef LUNCHBOX_LFVECTOR_ITERATOR_H
22 #define LUNCHBOX_LFVECTOR_ITERATOR_H
23 
24 #include <lunchbox/indexIterator.h>
25 
26 namespace lunchbox
27 {
34 template <class V, class T>
35 class LFVectorIterator : public IndexIterator<LFVectorIterator<V, T>, V, T>
36 {
38 
39 public:
41  LFVectorIterator(V* vector, size_t i)
42  : Super(vector, i)
43  {
44  }
45 
47  template <class U, class W>
49  : Super(from)
50  {
51  }
52 
54  T& operator*() const { return (*Super::container_)[Super::i_]; }
56  T* operator->() const { return &(*Super::container_)[Super::i_]; }
58  T& operator[](const size_t& n) const
59  {
60  return (*Super::container_)[Super::i_ + n];
61  }
62 
63 private:
64  template <class, int32_t>
65  friend class LFVector; // LFVector::erase
66 };
67 }
68 
69 #endif // LUNCHBOX_LFVECTOR_ITERATOR_H
Counter-based, as opposed to pointer-based, iterator for any container.
Definition: indexIterator.h:38
An iterator for LFVector.
STL-like vector implementation providing certain thread-safety guarantees.
Definition: lfVector.h:54
LFVectorIterator(const LFVectorIterator< U, W > &from)
Copy-construct an iterator.
T & operator*() const
Dereference the element at the current position.
LFVectorIterator(V *vector, size_t i)
Construct an iterator for a given vector and position.
T & operator[](const size_t &n) const
Address the element at the given position.
Abstraction layer and common utilities for multi-threaded programming.
Definition: algorithm.h:29
T * operator->() const
Address the element at the current position.