source: branches/0.4-stable/yat/utility/Index.h @ 1620

Last change on this file since 1620 was 1620, checked in by Peter, 14 years ago

correcting docs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef _theplu_yat_utility_index_
2#define _theplu_yat_utility_index_
3
4// $Id: Index.h 1620 2008-11-07 17:35:07Z 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 2 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 this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
27#include "SmartPtr.h"
28
29#include <vector>
30
31namespace theplu {
32namespace yat {
33namespace utility {
34
35  /**
36     \brief Class for storing indices of, e.g., a MatrixLookup.
37
38     This class is basically a wrapper around std::vector<size_t>. The
39     major differences are that the class is constant and copying is
40     performed in constant time (shallow copy).
41   */
42  class Index
43  {
44  public:
45    /**
46       Creates an empty Index
47     */
48    Index(void);
49
50    /**
51       Created Index will satisfy a[i] = i.
52       \param n size of created Index
53    */
54    Index(size_t n);
55
56    /**
57       Constructed Index c will satisfy c[i]=a[b[i]]
58     */
59    Index(const Index& a, const Index& b);
60
61    /**
62       \brief Constructor
63     */
64    explicit Index(const SmartPtr<const std::vector<size_t> >& vec);
65
66    /**
67       \brief Constructor
68
69       vec is copied
70     */
71    explicit Index(const std::vector<size_t>& vec);
72
73    /**
74       \brief access operator
75    */
76    const size_t& operator[](size_t) const;
77
78    /**
79       \brief number of elements
80    */
81    size_t size(void) const;
82
83    /**
84       \return underlying vector
85    */
86    const std::vector<size_t>& vector(void) const;
87
88  private:
89    // using compiler generated copy
90    // Index(const Index&);
91    // const Index& operator=(const Index&);
92
93    SmartPtr<const std::vector<size_t> > index_;
94  };
95
96}}} // of namespace utility, yat, and theplu
97
98#endif
Note: See TracBrowser for help on using the repository browser.