From 4be834ea2ec7702b71ce9f77bc4aeebd059f942c Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Tue, 22 Sep 2009 16:55:48 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@71 ed2142bd-67ad-457f-ba7c-d818d4011675 --- data_sets/shared_table_data_set.hpp | 131 ++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 data_sets/shared_table_data_set.hpp (limited to 'data_sets') diff --git a/data_sets/shared_table_data_set.hpp b/data_sets/shared_table_data_set.hpp new file mode 100644 index 0000000..1e9b743 --- /dev/null +++ b/data_sets/shared_table_data_set.hpp @@ -0,0 +1,131 @@ +/** + \file default_data_set.hpp + */ + +#ifndef SHARED_TABLE_DATA_SET +#define SHARED_TABLE_DATA_SET +#define OPT_HEADER +#include "core/fitter.hpp" +#include + + +namespace opt_utilities +{ + + /** + \brief shared_table implement of the data set + \tparam Ty type of y + \tparam Tx type of x + */ + template + class shared_table_data_set + :public data_set + { + // private: + public: + std::vector > data_vec; + + data_set* do_clone()const + { + return (data_set*)(this); + } + + void do_destroy() + { + } + + + const data& do_get_data(size_t i)const + { + return data_vec.at(i); + } + + void do_set_data(size_t i,const data& d) + { + data_vec.at(i)=d; + } + + size_t do_size()const + { + return data_vec.size(); + } + + void do_add_data(const data& d) + { + data_vec.push_back(d); + } + + void do_clear() + { + data_vec.clear(); + } + + bool insert_data(size_t idx,const data& d) + { + if(idx<0||idx>data_vec.size()) + { + return false; + } + data_vec.insert(data_vec.begin()+idx,d); + return true; + } + + bool erase_data(size_t idx) + { + if(idx>=0&&idx=0&&beg& rhs) + :data_vec(rhs.data_vec) + {} + + shared_table_data_set(const data_set& rhs) + { + data_vec.resize(rhs.size()); + for(int i=0;i& rhs) + { + data_vec=rhs.data_vec; + return *this; + } + + shared_table_data_set& operator=(const data_set& rhs) + { + data_vec.resize(rhs.size()); + for(int i=0;i