1#ifndef CYCLUS_SRC_TOOLKIT_RES_MAP_H_
2#define CYCLUS_SRC_TOOLKIT_RES_MAP_H_
40template <
class K,
class R>
50 typedef typename std::map<K, typename R::Ptr>
map_type;
51 typedef typename std::map<K, typename R::Ptr>::iterator
iterator;
52 typedef typename std::map<K, typename R::Ptr>::const_iterator
const_iterator;
63 inline int size()
const {
return resources_.size(); }
75 for (;
it != resources_.end(); ++
it) {
76 obj_ids_[
it->first] =
it->second->obj_id();
83 dirty_quantity_ =
true;
87 inline bool empty()
const {
return resources_.empty(); }
95 dirty_quantity_ =
true;
101 dirty_quantity_ =
true;
102 return const_cast<map_type&
>(resources_)[k];
107 dirty_quantity_ =
true;
108 return resources_.begin();
119 dirty_quantity_ =
true;
120 return resources_.end();
136 typename map_type::size_type
erase(
const K& k) {
137 typename map_type::size_type
s = resources_.erase(k);
152 dirty_quantity_ =
true;
162 int n = resources_.size();
163 std::vector<typename R::Ptr> vals (n);
165 while (
it != resources_.end()) {
166 vals[i] =
it->second;
179 void Values(std::vector<typename R::Ptr> vals) {
182 for (;
oit != obj_ids_.end(); ++
oit) {
188 resources_[
lookup[vals[i]->obj_id()]] = vals[i];
190 dirty_quantity_ =
true;
201 typename R::Ptr
Pop(
const K key) {
203 if (
it == resources_.end()) {
204 std::stringstream
ss;
205 ss <<
"key " << key <<
" could not be found";
208 typename R::Ptr val =
it->second;
209 resources_.erase(
it);
210 dirty_quantity_ =
true;
216 void UpdateQuantity() {
220 int n = resources_.size();
225 while (
it != resources_.end()) {
226 qtys[i] = (*(
it->second)).quantity();
232 dirty_quantity_ =
false;
236 mutable bool dirty_quantity_;
static double KahanSum(std::vector< double > input)
sums the materials in the vector in an intelligent way, to avoid floating point issues.
For failed retrieval/insertion of key-based data into/from data structures.
Declares the CycArithmetic class, which holds arithmetic algorithms.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters