Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:49:31

0001 #include <map>
0002 
0003 #include "DataFormats/Common/interface/SortedCollection.h"
0004 
0005 
0006 // A very simple (but not built-in KEY type)
0007 struct Key
0008 {
0009   int i;
0010 };
0011 
0012 
0013 // KEYS must be less-than comparable.
0014 // This means, if k1 and k2 are objects of type K,
0015 // then the expression
0016 //     k1 < k2
0017 // must define a strict weak ordering, and the result
0018 // must be convertible to bool.
0019 // Numeric types automatically satisfy this.
0020 
0021 bool operator< (Key const& a, Key const& b) { return a.i < b.i; }
0022 
0023 struct V
0024 {
0025   typedef Key key_type;
0026 
0027   int i;
0028   key_type k;
0029 
0030   key_type id() const { return k; }  
0031 };
0032 
0033 struct BackwardsOrdering
0034 {
0035   typedef Key key_type;
0036   bool operator()(key_type a, V const& b) const { return b.id() < a; }
0037   bool operator()(V const& a, key_type b) const { return b < a.id(); }
0038   bool operator()(V const& a, V const& b) const { return b.id() < a.id(); }  
0039 };
0040 
0041 int main()
0042 {
0043   edm::SortedCollection<V> sc;
0044   std::map<Key,V>          m;
0045 
0046   // Fill with 2000 entries; includes sorting.
0047 
0048   // Do 2000 finds
0049 
0050   return 0;
0051 }