iRoCS Toolbox  1.1.0
adjustUniqueIDs.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title: simple functions to adjust the uniqueID's of feature vectors
26 ** $RCSfile$
27 ** $Revision: 4820 $$Name$
28 ** $Date: 2011-11-08 10:57:01 +0100 (Tue, 08 Nov 2011) $
29 ** Copyright: GPL $Author: tschmidt $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.3 2005/01/28 14:03:30 fehr
38 ** some include bugfixing for external library use
39 **
40 ** Revision 1.2 2004/09/03 09:12:41 ronneber
41 ** - uses Accessor now
42 **
43 ** Revision 1.1 2004/08/26 08:36:59 ronneber
44 ** initital import
45 **
46 **
47 **
48 **************************************************************************/
49 
50 #ifndef ADJUSTUNIQUEIDS_HH
51 #define ADJUSTUNIQUEIDS_HH
52 
53 #ifdef HAVE_CONFIG_H
54 #include <config.hh>
55 #endif
56 
57 #include "DirectAccessor.hh"
58 #include "DereferencingAccessor.hh"
59 #include <cstddef>
60 
61 namespace svt
62 {
63 
64  template<typename ForwardIter, typename Accessor>
65  void adjustUniqueIDs( const ForwardIter& fvBegin,
66  const ForwardIter& fvEnd,
67  Accessor accessor)
68  {
69  ptrdiff_t size = fvEnd - fvBegin;
70  ForwardIter p = fvBegin;
71  for(ptrdiff_t i = 0; i < size; ++i, ++p)
72  {
73  accessor(p).setUniqueID(static_cast<unsigned int>(i));
74  }
75  }
76 
77  template< typename FV>
78  void adjustUniqueIDs( std::vector<FV*>& featureVectorPointers)
79  {
80  adjustUniqueIDs( featureVectorPointers.begin(),
81  featureVectorPointers.end(),
83  }
84 
85  template< typename FV>
86  void adjustUniqueIDs( std::vector<FV>& featureVectors)
87  {
88  adjustUniqueIDs( featureVectors.begin(),
89  featureVectors.end(),
90  DirectAccessor());
91  }
92 
93 
94 }
95 
96 #endif
void adjustUniqueIDs(const ForwardIter &fvBegin, const ForwardIter &fvEnd, Accessor accessor)