Lunchbox  1.8.0
lfVectorIterator.h
1 
2 /* Copyright (c) 2011-2012, 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 
29 template< class V, class T >
30 class LFVectorIterator : public IndexIterator< LFVectorIterator< V, T >, V, T >
31 {
33 
34 public:
35  LFVectorIterator() : Super( 0, 0 ) {}
36  LFVectorIterator( V* vector, size_t i ) : Super( vector, i ) {}
37  template< class U, class W >
38  LFVectorIterator( const LFVectorIterator< U, W >& from ) : Super( from ) {}
39 
40  T& operator*() const { return (*Super::container_)[ Super::i_ ]; }
41  T* operator->() const { return &(*Super::container_)[ Super::i_ ]; }
42  T& operator[]( const size_t& n ) const
43  { return (*Super::container_)[ Super::i_ + n ]; }
44 
45 private:
46  template< class, int32_t > friend class LFVector; // LFVector::erase
47 };
48 
49 }
50 
51 #endif // LUNCHBOX_LFVECTOR_ITERATOR_H