diff options
author | Roland Haas <rhaas@tapir.caltech.edu> | 2013-10-08 17:31:22 -0700 |
---|---|---|
committer | Roland Haas <rhaas@tapir.caltech.edu> | 2013-10-15 09:14:34 -0700 |
commit | 8237792551e9f5f9ca95e98d78a709b5722ed25f (patch) | |
tree | 6854b81359a9e350e4dd89047a9e301355d7a891 /Carpet/CarpetLib/src/defs.cc | |
parent | b13c69008fd5d9b0d04f417cec3c21f507e3a6f4 (diff) |
CarpetLib: use map instead of set for dh::gfs
some routines assume that elements in gfs are sorted by variable index
when traversing the container (eg recompose_allocate does)
Diffstat (limited to 'Carpet/CarpetLib/src/defs.cc')
-rw-r--r-- | Carpet/CarpetLib/src/defs.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Carpet/CarpetLib/src/defs.cc b/Carpet/CarpetLib/src/defs.cc index 02474b8b9..a888417b1 100644 --- a/Carpet/CarpetLib/src/defs.cc +++ b/Carpet/CarpetLib/src/defs.cc @@ -129,6 +129,19 @@ memoryof (set<T> const & c) return s; } +template <class S, class T> +size_t +memoryof (map<S,T> const & c) +{ + size_t s = sizeof c; + for (typename map<S,T>::const_iterator i=c.begin(); i!=c.end(); ++i) { + // Assume that there are three pointers per list element, forming + // a tree structure + s += 3 * sizeof (void *) + memoryof(i->second); + } + return s; +} + template <class T> size_t memoryof (stack<T> const & c) @@ -345,6 +358,7 @@ template size_t memoryof (set<dh*> const & l); template size_t memoryof (set<gh*> const & l); template size_t memoryof (set<gdata*> const & l); template size_t memoryof (set<ggf*> const & l); +template size_t memoryof (map<int,ggf*> const & l); template size_t memoryof (set<th*> const & l); template size_t memoryof (stack<void*> const & s); template size_t memoryof (vector<bool> const & v); @@ -419,6 +433,7 @@ template istream& input (istream& os, vector<vector<vector<region_t> > >& v); //template ostream& output (ostream& os, const list<ibbox>& l); //template ostream& output (ostream& os, const list<region_t>& l); +template ostream& output (ostream& os, const pair<int const, ggf*>& p); #ifdef CARPET_ENABLE_BBOXSET2 //template ostream& output (ostream& os, const map<int,shared_ptr<bboxset2::bboxset<int,0> > >& m); //template ostream& output (ostream& os, const map<int,shared_ptr<bboxset2::bboxset<int,1> > >& m); |