source: trunk/yat/utility/sort_index.h @ 1491

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

refs #439

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1#ifndef _theplu_yat_utility_sort_index_
2#define _theplu_yat_utility_sort_index_
3
4// $Id: sort_index.h 1491 2008-09-11 22:41:30Z 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 "StrideIterator.h"
26
27#include <gsl/gsl_sort.h>
28
29#include <vector>
30
31namespace theplu {
32namespace yat {
33namespace utility {
34
35  /**
36     Create a vector \a sort_index containing the indeces of elements
37     in a range [first, last). The elements of \a sort_index give the
38     index of the range element which would have been stored in that
39     position if the range had been sorted in place. The first element
40     of \a sort_index gives the index of the least element in the
41     range, and the last element of \a sort_index gives the index of
42     the greatest element in the range. The function will not affect
43     the range, i.e., ForwardIterator can be read-only.
44  */
45  template<typename ForwardIterator>
46  void sort_index(ForwardIterator first, ForwardIterator last, 
47                  std::vector<size_t>& sort_index);
48   
49   
50  /**
51     Specialization for StrideIterator<double*>
52  */
53  void sort_index(StrideIterator<double*> first, 
54                  StrideIterator<double*> last, 
55                  std::vector<size_t>& sort_index);
56
57  /**
58     Specialization for StrideIterator<const double*>
59  */
60  void sort_index(StrideIterator<const double*> first, 
61                  StrideIterator<const double*> last, 
62                  std::vector<size_t>& sort_index);
63
64  /**
65     Specialization for std::vector<double>::iterator
66  */
67  void sort_index(std::vector<double>::iterator first, 
68                  std::vector<double>::iterator last, 
69                  std::vector<size_t>& sort_index);
70
71  /**
72     Specialization for std::vector<double>::const_iterator
73  */
74  void sort_index(std::vector<double>::const_iterator first, 
75                  std::vector<double>::const_iterator last, 
76                  std::vector<size_t>& sort_index);
77
78
79
80}}} // of namespace utility, yat, and theplu
81
82#endif
Note: See TracBrowser for help on using the repository browser.