void serialize(storage_type& s) const { s.serialize(mFirstX); s.serialize(mXW); s.serialize(mW); s.serialize(mXXW); }
static void serialize(storage_type& s, const Nullable<T>& in) { bool is = in.isValue(); s.serialize(is); if (is) s.serialize(*in); }
void deserialize(storage_type& s) { s.deserialize(mFirstX); s.deserialize(mXW); s.deserialize(mW); s.deserialize(mXXW); }
static void serialize(storage_type& s, const boost::unordered_set<T>& o) { uint32_t sz = o.size(); s.serialize(sz); for (auto it = o.begin(), it_end = o.end(); it != it_end; ++it) s.serialize(*it); }
static void serialize(storage_type& s, const Alternative<T1, T2>& in) { s.serialize(in.isLeft()); if (in.isLeft()) s.serialize(in.left()); else s.serialize(in.right()); }
static void serialize(storage_type& s, const boost::unordered_map<T1, T2>& o) { uint32_t sz = o.size(); s.serialize(sz); for (typename boost::unordered_map<T1,T2>::const_iterator it = o.begin(), it_end = o.end(); it != it_end; ++it) { s.serialize(it->first); s.serialize(it->second); } }
static void serialize(storage_type& s, const MapWithIndex<T1, T2, cmp_type_1, cmp_type_2>& o) { uint32_t sz = o.size(); s.serialize(sz); for (auto it = o.getKeyToValue().begin(), it_end = o.getKeyToValue().end(); it != it_end; ++it) { s.serialize(it->first); s.serialize(it->second); } }
static void deserialize(storage_type& s, boost::unordered_set<T>& o) { o = boost::unordered_set<T>(); uint32_t sz; s.deserialize(sz); for (int32_t k = 0; k < sz; k++) { T key; s.deserialize(key); o.insert(key); } }
static void deserialize(storage_type& s, boost::unordered_map<T1, T2>& o) { o = boost::unordered_map<T1,T2>(); uint32_t sz; s.deserialize(sz); for (int32_t k = 0; k < sz; k++) { T1 key; s.deserialize(key); s.deserialize(o[key]); } }
static void deserialize(storage_type& s, Nullable<T>& out) { bool n; s.deserialize(n); if (n) { T t; s.deserialize(t); out = t; } else out = null(); }
indexmap_storage_pair (const indexmap_type & IM, const storage_type & ST): indexmap_(IM),storage_(ST){ #ifdef TRIQS_ARRAYS_CHECK_IM_STORAGE_COMPAT if (ST.size() != IM.domain().number_of_elements()) TRIQS_RUNTIME_ERROR<<"index_storage_pair construction : storage and indices are not compatible"; #endif }
static void deserialize(storage_type& s, MapWithIndex<T1, T2, cmp_type_1, cmp_type_2>& o) { o = MapWithIndex<T1,T2, cmp_type_1, cmp_type_2>(); uint32_t sz; s.deserialize(sz); for (uint32_t k = 0; k < sz; k++) { T1 key; T2 val; s.deserialize(key); s.deserialize(val); o.set(key,val); } }
static void deserialize(storage_type& s, Alternative<T1, T2>& in) { bool isLeft; s.deserialize(isLeft); if (isLeft) { T1 t1; s.deserialize(t1); in = Alternative<T1, T2>(t1); } else { T2 t2; s.deserialize(t2); in = Alternative<T1, T2>(t2); } }
EvalType eval() { EvalType prod(1); iterator end_it(prime_factors.end()); for (iterator it(prime_factors.begin()); it != end_it; it++) { if (it->second) { if (it->second > 0) prod *= gsse::slow_power(it->first, it->second); else prod /= gsse::slow_power(it->first, -it->second); } } return prod; }
/** * gets the value associated with a key. * Returns (true, Value) if the entry is available. * Returns (false, undefined) otherwise. */ std::pair<bool, ValueType> get(const KeyType &key) const { // who owns the data? const size_t hashvalue = hasher(key); const size_t owningmachine = hashvalue % rpc.numprocs(); std::pair<bool, ValueType> retval; // if it is me, we can return it if (owningmachine == rpc.dc().procid()) { lock.lock(); typename storage_type::const_iterator iter = storage.find(hashvalue); retval.first = iter != storage.end(); if (retval.first) retval.second = iter->second; lock.unlock(); } else { retval = rpc.remote_request(owningmachine, &dht<KeyType,ValueType>::get, key); } return retval; }
static void init(storage_type& storage,rvalue_source_type t) { storage.reset(new T(static_cast<rvalue_source_type>(t))); }
static void cleanup(storage_type& storage) { storage.reset(); }
const_iterator end() const { return const_iterator( storage.end(), storage.end() ); }
static void init(storage_type& storage,source_reference_type t) { storage.reset(new T(t)); }
iterator end() { return iterator( storage.end(), storage.end() ); }
const_iterator begin() const { return const_iterator( storage.begin(), storage.end() ); }
static pointer get_pointer(index_type i, storage_type& stg) { pointer p=stg.end(); p.set_address(i); return p; }
iterator begin() { return iterator( storage.begin(), storage.end() ); }
void destroy() { static_cast< T* >(storage.address())->~T(); }
T& value() { return *static_cast< T* >(storage.address()); }
void store(duration const& d) { cont_.push_front(d); }
void reset() { cont_.clear(); }
duration last() const { if (cont_.empty()) return duration::zero(); else return *cont_.begin(); }
duration elapsed() const { duration elapsed_ = duration::zero(); for (const_iterator it = cont_.begin(); it !=cont_.end(); ++it) elapsed_ += *it; return elapsed_; }
/** Must be called by all machines simultaneously */ void clear() { rpc.barrier(); storage.clear(); }