source: trunk/src/gslapi_utility.cc @ 257

Last change on this file since 257 was 257, checked in by Jari Häkkinen, 18 years ago

Added vector views and made vector member functions to be non-member functions.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 601 bytes
Line 
1// $Id: gslapi_utility.cc 257 2005-03-04 00:53:34Z jari $
2
3#include "gslapi_utility.h"
4#include <utility>
5
6#include "vector.h"
7
8
9namespace theplu {
10namespace gslapi {
11
12
13  std::pair<size_t,
14            size_t> minmax_index(const vector& vec,
15                                 const std::vector<size_t>& subset)
16  {
17    size_t min_index = subset[0];
18    size_t max_index = subset[0];
19    for (unsigned int i=1; i<subset.size(); i++) {
20      if (vec[subset[i]] < vec[min_index])
21        min_index = subset[i];
22      else if (vec[subset[i]] > vec[max_index])
23        max_index = subset[i];
24    }
25    return std::pair<size_t,size_t>(min_index, max_index);
26  }
27
28}} // of namespace gslapi and namespace thep
Note: See TracBrowser for help on using the repository browser.