Line data Source code
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 :
29 : /**
30 : * An iterator for LFVector.
31 : *
32 : * @tparam V the LFVector type
33 : * @tparam T the LFVector element type
34 : */
35 : template< class V, class T >
36 3 : class LFVectorIterator : public IndexIterator< LFVectorIterator< V, T >, V, T >
37 : {
38 : typedef IndexIterator< LFVectorIterator< V, T >, V, T > Super;
39 :
40 : public:
41 : /** Construct an iterator for a given vector and position. @version 1.8 */
42 2002281 : LFVectorIterator( V* vector, size_t i ) : Super( vector, i ) {}
43 :
44 : /** Copy-construct an iterator. @version 1.8 */
45 : template< class U, class W >
46 2000002 : LFVectorIterator( const LFVectorIterator< U, W >& from ) : Super( from ) {}
47 :
48 : /** Dereference the element at the current position. @version 1.8 */
49 79602590 : T& operator*() const { return (*Super::container_)[ Super::i_ ]; }
50 :
51 : /** Address the element at the current position. @version 1.8 */
52 : T* operator->() const { return &(*Super::container_)[ Super::i_ ]; }
53 :
54 : /** Address the element at the given position. @version 1.8 */
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
|