Debian Codegraph @

src/linear_index.cc

raw
1 /*
2 * This file is part of MUSIC.
3 * Copyright (C) 2007, 2008, 2009 INCF
4 *
5 * MUSIC is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * MUSIC is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "music/linear_index.hh"
20
21 namespace MUSIC {
22
23 LinearIndex::iterator::iterator (LinearIndex* li)
24 : indices_ (li)
25 {
26 }
27
28
29 const IndexInterval
30 LinearIndex::iterator::operator* ()
31 {
32 return indices_->interval_;
33 }
34
35
36 const IndexInterval*
37 LinearIndex::iterator::dereference ()
38 {
39 return &indices_->interval_;
40 }
41
42
43 void
44 LinearIndex::iterator::operator++ ()
45 {
46 indices_ = 0;
47 }
48
49
50 bool
51 LinearIndex::iterator::isEqual (IteratorImplementation* i) const
52 {
53 return indices_ == static_cast<iterator*> (i)->indices_;
54 }
55
56
57 LinearIndex::LinearIndex (GlobalIndex baseindex, int size)
58 : interval_ (baseindex, baseindex + size, static_cast<int> (baseindex))
59 {
60
61 }
62
63
64 IndexMap::iterator
65 LinearIndex::begin ()
66 {
67 return IndexMap::iterator (new iterator (this));
68 }
69
70
71 const IndexMap::iterator
72 LinearIndex::end () const
73 {
74 return IndexMap::iterator (new iterator (0));
75 }
76
77
78 IndexMap*
79 LinearIndex::copy ()
80 {
81 return new LinearIndex (*this);
82 }
83
84 }