CMS 3D CMS Logo

Algorithms.h

Go to the documentation of this file.
00001 #ifndef FWCore_Utilities_Algorithms_h
00002 #define FWCore_Utilities_Algorithms_h
00003 
00004 #include <algorithm>
00005 
00006 namespace edm {
00007 
00011 
00013   template <typename ForwardSequence, typename Func>
00014   inline
00015   Func
00016   for_all(ForwardSequence& s, Func f) {
00017     return std::for_each(s.begin(), s.end(), f);
00018   }
00019 
00021   template <typename ForwardSequence, typename Func>
00022   inline
00023   Func
00024   copy_all(ForwardSequence& s, Func f) {
00025     return std::copy(s.begin(), s.end(), f);
00026   }
00027 
00029   template <typename ForwardSequence, typename Datum>
00030   inline
00031   typename ForwardSequence::const_iterator
00032   find_in_all(ForwardSequence const& s, Datum const& d) {
00033     return std::find(s.begin(), s.end(), d);
00034   }
00035 
00036   template <typename ForwardSequence, typename Datum>
00037   inline
00038   typename ForwardSequence::iterator
00039   find_in_all(ForwardSequence& s, Datum const& d) {
00040     return std::find(s.begin(), s.end(), d);
00041   }
00042 
00043   template <typename ForwardSequence, typename Datum>
00044   inline
00045   bool
00046   search_all(ForwardSequence const& s, Datum const& d) {
00047     return std::find(s.begin(), s.end(), d) != s.end();
00048   }
00049 
00051   template <typename ForwardSequence, typename Datum>
00052   inline
00053   bool
00054   binary_search_all(ForwardSequence const& s, Datum const& d) {
00055     return std::binary_search(s.begin(), s.end(), d);
00056   }
00057 
00059   template <typename ForwardSequence, typename Datum>
00060   inline
00061   typename ForwardSequence::const_iterator
00062   lower_bound_all(ForwardSequence const& s, Datum const& d) {
00063     return std::lower_bound(s.begin(), s.end(), d);
00064   }
00065 
00066   template <typename ForwardSequence, typename Datum>
00067   inline
00068   typename ForwardSequence::iterator
00069   lower_bound_all(ForwardSequence& s, Datum const& d) {
00070     return std::lower_bound(s.begin(), s.end(), d);
00071   }
00072 
00073   template <typename ForwardSequence, typename Datum, typename Predicate>
00074   inline
00075   typename ForwardSequence::const_iterator
00076   lower_bound_all(ForwardSequence const& s, Datum const& d, Predicate p) {
00077     return std::lower_bound(s.begin(), s.end(), d, p);
00078   }
00079 
00080   template <typename ForwardSequence, typename Datum, typename Predicate>
00081   inline
00082   typename ForwardSequence::iterator
00083   lower_bound_all(ForwardSequence& s, Datum const& d, Predicate p) {
00084     return std::lower_bound(s.begin(), s.end(), d, p);
00085   }
00086 
00088   template <typename RandomAccessSequence>
00089   inline
00090   void
00091   sort_all(RandomAccessSequence & s) {
00092     std::sort(s.begin(), s.end());
00093   }
00094 
00095   template <typename RandomAccessSequence, typename Predicate>
00096   inline
00097   void
00098   sort_all(RandomAccessSequence & s, Predicate p) {
00099     std::sort(s.begin(), s.end(), p);
00100   }
00101 
00103   template <typename RandomAccessSequence>
00104   inline
00105   void
00106   stable_sort_all(RandomAccessSequence & s) {
00107     std::stable_sort(s.begin(), s.end());
00108   }
00109 
00110   template <typename RandomAccessSequence, typename Predicate>
00111   inline
00112   void
00113   stable_sort_all(RandomAccessSequence & s, Predicate p) {
00114     std::stable_sort(s.begin(), s.end(), p);
00115   }
00116 }
00117 #endif

Generated on Tue Jun 9 17:36:41 2009 for CMSSW by  doxygen 1.5.4