ATLAS Offline Software
Loading...
Searching...
No Matches
FSmap.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ISF_FSmap_H
6#define ISF_FSmap_H
7
8#include<map>
9#include<math.h>
10
11template <class _Key, class _Tp > class FSmap : public std::map< _Key , _Tp > {
12public:
13 typedef _Key key_type;
14 typedef typename std::map< _Key , _Tp >::iterator iterator;
15 typedef typename std::map< _Key , _Tp >::const_iterator const_iterator;
16
18 if(std::map< _Key , _Tp >::size()==0) return std::map< _Key , _Tp >::end();
19 const_iterator i=std::map< _Key , _Tp >::lower_bound(k);
20 if(i==std::map< _Key , _Tp >::end()) {
21 --i;
22 return i;
23 }
24 if(i==std::map< _Key , _Tp >::begin()) return i;
25
26 const_iterator il=i;
27 --il;
28
29 if( fabs(il->first - k) > fabs(i->first - k) ) return i;
30 else return il;
31 };
33 if(std::map< _Key , _Tp >::size()==0) return std::map< _Key , _Tp >::end();
34 iterator i=std::map< _Key , _Tp >::lower_bound(k);
35 if(i==std::map< _Key , _Tp >::end()) {
36 --i;
37 return i;
38 }
39 if(i==std::map< _Key , _Tp >::begin()) return i;
40
41 iterator il=i;
42 --il;
43
44 if( fabs(il->first - k) > fabs(i->first - k) ) return i;
45 else return il;
46 };
47};
48
49#endif
Definition FSmap.h:11
std::map< _Key, _Tp >::const_iterator const_iterator
Definition FSmap.h:15
std::map< _Key, _Tp >::iterator iterator
Definition FSmap.h:14
const_iterator find_closest(const key_type &k) const
Definition FSmap.h:17
_Key key_type
Definition FSmap.h:13
iterator find_closest(const key_type &k)
Definition FSmap.h:32