Lunchbox  1.11.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 {
28 
35 template< class V, class T >
36 class LFVectorIterator : public IndexIterator< LFVectorIterator< V, T >, V, T >
37 {
39 
40 public:
42  LFVectorIterator( V* vector, size_t i ) : Super( vector, i ) {}
43 
45  template< class U, class W >
46  LFVectorIterator( const LFVectorIterator< U, W >& from ) : Super( from ) {}
47 
49  T& operator*() const { return (*Super::container_)[ Super::i_ ]; }
50 
52  T* operator->() const { return &(*Super::container_)[ Super::i_ ]; }
53 
55  T& operator[]( const size_t& n ) const
56  { return (*Super::container_)[ Super::i_ + n ]; }
57 
58 private:
59  template< class, int32_t > friend class LFVector; // LFVector::erase
60 };
61 
62 }
63 
64 #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:53
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.
T * operator->() const
Address the element at the current position.