//////////////////////////////////////////////////////////////////////////////// // Author: Andy Rushton // Copyright: (c) Southampton University 1999-2004 // (c) Andy Rushton 2004-2009 // License: BSD License, see ../docs/license.html //////////////////////////////////////////////////////////////////////////////// #include "persistent_int.hpp" namespace stlplus { //////////////////////////////////////////////////////////////////////////////// template void dump_multiset(dump_context& context, const std::multiset& data, D dump_fn) throw(persistent_dump_failed) { dump_unsigned(context,data.size()); for (typename std::multiset::const_iterator i = data.begin(); i != data.end(); i++) dump_fn(context,*i); } template void restore_multiset(restore_context& context, std::multiset& data, R restore_fn) throw(persistent_restore_failed) { data.clear(); unsigned size = 0; restore_unsigned(context,size); typename std::multiset::iterator i = data.begin(); for (unsigned j = 0; j < size; j++) { K key; restore_fn(context,key); // inserting using an iterator is O(n) rather than O(n*log(n)) i = data.insert(i, key); } } //////////////////////////////////////////////////////////////////////////////// } // end namespace stlplus