OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
stage
include
ost
seq
impl
sequence_list_iterator.hh
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
// This file is part of the OpenStructure project <www.openstructure.org>
3
//
4
// Copyright (C) 2008-2011 by the OpenStructure authors
5
//
6
// This library is free software; you can redistribute it and/or modify it under
7
// the terms of the GNU Lesser General Public License as published by the Free
8
// Software Foundation; either version 3.0 of the License, or (at your option)
9
// any later version.
10
// This library is distributed in the hope that it will be useful, but WITHOUT
11
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
// details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with this library; if not, write to the Free Software Foundation, Inc.,
17
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
//------------------------------------------------------------------------------
19
#ifndef OST_SEQ_IMPL_SEQUENCE_LIST_ITERATOR_HH
20
#define OST_SEQ_IMPL_SEQUENCE_LIST_ITERATOR_HH
21
22
/*
23
Author: Marco Biasini
24
*/
25
26
#include <
ost/seq/module_config.hh
>
27
namespace
ost {
namespace
seq {
namespace
impl {
28
30
template
<
typename
T,
typename
I>
31
class
TEMPLATE_EXPORT
SequenceListIterator
32
:
public
std::iterator<std::random_access_iterator_tag, T>{
33
public
:
34
typedef
T
ValueType
;
35
typedef
I
IteratorType
;
36
typedef
SequenceListIterator<T, I>
ClassType
;
37
protected
:
38
void
UpdateVal()
39
{
40
if
(current_it_<end_) {
41
current_val_=
ValueType
(*current_it_);
42
}
43
}
44
public
:
45
SequenceListIterator
(
IteratorType
it,
IteratorType
end
):
46
current_it_(it), end_(end)
47
{
48
this->UpdateVal();
49
}
50
51
ValueType
&
operator*
()
52
{
53
return
current_val_;
54
}
55
56
ValueType
* operator->()
57
{
58
return
¤t_val_;
59
}
60
61
ClassType
&
operator++
() {
62
++current_it_;
63
this->UpdateVal();
64
return
*
this
;
65
}
66
67
ClassType
&
operator+=
(
int
n) {
68
current_it_+=n;
69
this->UpdateVal();
70
return
*
this
;
71
}
72
ClassType
operator+
(
int
n) {
73
ClassType
ans(current_it_, end_);
74
ans+=n;
75
return
*
this
;
76
}
77
ClassType
&
operator-=
(
int
n) {
78
current_it_-=n;
79
this->UpdateVal();
80
return
*
this
;
81
}
82
83
ClassType
operator++
(
int
) {
84
ClassType
ans(*
this
);
85
++current_it_;
86
this->UpdateVal();
87
return
ans;
88
}
89
90
bool
operator==
(
const
ClassType
& rhs)
const
91
{
92
return
current_it_==rhs.current_it_;
93
}
94
95
bool
operator!=
(
const
ClassType
& rhs)
const
96
{
97
return
!(*
this
==rhs);
98
}
99
private
:
100
IteratorType current_it_;
101
IteratorType end_;
102
ValueType current_val_;
103
};
104
105
}}}
106
107
#endif
Generated on Thu Mar 5 2015 15:19:07 for OpenStructure by
1.8.1.1