source: trunk/yat/utility/Index.h @ 1615

Last change on this file since 1615 was 1528, checked in by Peter, 13 years ago

refs #444 - started using boost::permutation_iterator for vector iterators from MatrixLookup? and also removed stride layer for const_iterator (stride was always 1).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1#ifndef _theplu_yat_utility_index_
2#define _theplu_yat_utility_index_
3
4// $Id: Index.h 1528 2008-09-24 15:46:28Z peter $
5
6/*
7  Copyright (C) 2008 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "SmartPtr.h"
26
27#include <vector>
28
29namespace theplu {
30namespace yat {
31namespace utility {
32
33  ///
34  /// Internal Class keeping track of which samples are support vectors and
35  /// not. The first nof_sv elements in the vector are indices of the
36  /// support vectors
37  ///
38  class Index
39  {
40  public:
41    /**
42       Read only iterator
43
44       \since New in yat 0.5
45     */
46    typedef std::vector<size_t>::const_iterator const_iterator;
47
48    /**
49       Creates an empty Index
50     */
51    Index(void);
52
53    /**
54       Created Index will satisfy a[i] = i.
55       \param n size of created Index
56    */
57    explicit Index(size_t n);
58
59    /**
60       Constructed Index c will satisfy c[i]=a[b[i]]
61     */
62    Index(const Index& a, const Index& b);
63
64    /**
65       \brief Constructor
66     */
67    explicit Index(const SmartPtr<const std::vector<size_t> >& vec);
68
69    /**
70       \brief Constructor
71
72       vec is copied
73     */
74    explicit Index(const std::vector<size_t>& vec);
75
76    /**
77       \return iterator pointing to first element of Index
78
79       \since New in yat 0.5
80     */
81    const_iterator begin(void) const;
82
83    /**
84       \return iterator pointing to element one passed last Index
85
86       \since New in yat 0.5
87     */
88    const_iterator end(void) const;
89
90    /**
91       \brief access operator
92    */
93    const size_t& operator[](size_t) const;
94
95    /**
96       \brief number of elements
97    */
98    size_t size(void) const;
99
100    /**
101       \return underlying vector
102    */
103    const std::vector<size_t>& vector(void) const;
104
105  private:
106    // using compiler generated copy
107    // Index(const Index&);
108    // const Index& operator=(const Index&);
109
110    SmartPtr<const std::vector<size_t> > index_;
111  };
112
113}}} // of namespace utility, yat, and theplu
114
115#endif
Note: See TracBrowser for help on using the repository browser.