From 08a80dfc767f3ff4c362ae2fa3a16a138d336492 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Thu, 2 Apr 2009 12:57:55 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@13 ed2142bd-67ad-457f-ba7c-d818d4011675 --- core/sorted_data_set.hpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 core/sorted_data_set.hpp (limited to 'core/sorted_data_set.hpp') diff --git a/core/sorted_data_set.hpp b/core/sorted_data_set.hpp new file mode 100644 index 0000000..f825b6c --- /dev/null +++ b/core/sorted_data_set.hpp @@ -0,0 +1,57 @@ +#ifndef SORTED_DATA_SET +#define SORTED_DATA_SET +#include "fitter.hpp" +#include +#include + +namespace opt_utilities +{ + + template + bool comp_data(const data& d1,const data& d2) + { + return d1.get_x() +class sorted_data_set + :public data_set +{ +private: + std::vector > data_vec; + + data_set* do_clone()const + { + return new sorted_data_set(*this); + } + + + const data& do_get_data(size_t i)const + { + return data_vec.at(i); + } + + size_t do_size()const + { + return data_vec.size(); + } + + void do_add_data(const data& d) + { + typename std::vector >::iterator p + =std::lower_bound(data_vec.begin(),data_vec.end(),d,comp_data); + //data_vec.push_back(d); + data_vec.insert(p,d); + } + + void do_clear() + { + data_vec.clear(); + } + +}; +} + +#endif +//EOF -- cgit v1.2.2