aboutsummaryrefslogtreecommitdiffstats
path: root/data_sets
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-04-06 16:36:52 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-04-06 16:36:52 +0000
commitceb836399f56b60ad82a73e67f4cbd361d834582 (patch)
treeff410afea4b18b729d453942db7ce951f9df0804 /data_sets
parentb025e3add3aeb1e5e79ba167398fbce8f4d75b21 (diff)
downloadopt-utilities-ceb836399f56b60ad82a73e67f4cbd361d834582.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@18 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'data_sets')
-rw-r--r--data_sets/default_data_set.hpp47
-rw-r--r--data_sets/sorted_data_set.hpp57
2 files changed, 104 insertions, 0 deletions
diff --git a/data_sets/default_data_set.hpp b/data_sets/default_data_set.hpp
new file mode 100644
index 0000000..887e3d2
--- /dev/null
+++ b/data_sets/default_data_set.hpp
@@ -0,0 +1,47 @@
+#ifndef DEFAULT_DATA_SET
+#define DEFAULT_DATA_SET
+#include "core/fitter.hpp"
+#include <vector>
+
+
+namespace opt_utilities
+{
+
+template <typename Ty,typename Tx>
+class default_data_set
+ :public data_set<Ty,Tx>
+{
+private:
+ std::vector<data<Ty,Tx> > data_vec;
+
+ data_set<Ty,Tx>* do_clone()const
+ {
+ return new default_data_set<Ty,Tx>(*this);
+ }
+
+
+ const data<Ty,Tx>& 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<Ty,Tx>& d)
+ {
+ data_vec.push_back(d);
+ }
+
+ void do_clear()
+ {
+ data_vec.clear();
+ }
+
+};
+}
+
+#endif
+//EOF
diff --git a/data_sets/sorted_data_set.hpp b/data_sets/sorted_data_set.hpp
new file mode 100644
index 0000000..f12edac
--- /dev/null
+++ b/data_sets/sorted_data_set.hpp
@@ -0,0 +1,57 @@
+#ifndef SORTED_DATA_SET
+#define SORTED_DATA_SET
+#include "core/fitter.hpp"
+#include <vector>
+#include <algorithm>
+
+namespace opt_utilities
+{
+
+ template <typename Ty,typename Tx>
+ bool comp_data(const data<Ty,Tx>& d1,const data<Ty,Tx>& d2)
+ {
+ return d1.get_x()<d2.get_x();
+ }
+
+
+template <typename Ty,typename Tx>
+class sorted_data_set
+ :public data_set<Ty,Tx>
+{
+private:
+ std::vector<data<Ty,Tx> > data_vec;
+
+ data_set<Ty,Tx>* do_clone()const
+ {
+ return new sorted_data_set<Ty,Tx>(*this);
+ }
+
+
+ const data<Ty,Tx>& 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<Ty,Tx>& d)
+ {
+ typename std::vector<data<Ty,Tx> >::iterator p
+ =std::lower_bound(data_vec.begin(),data_vec.end(),d,comp_data<Ty,Tx>);
+ //data_vec.push_back(d);
+ data_vec.insert(p,d);
+ }
+
+ void do_clear()
+ {
+ data_vec.clear();
+ }
+
+};
+}
+
+#endif
+//EOF