From 8237792551e9f5f9ca95e98d78a709b5722ed25f Mon Sep 17 00:00:00 2001 From: Roland Haas Date: Tue, 8 Oct 2013 17:31:22 -0700 Subject: 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) --- Carpet/CarpetLib/src/defs.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Carpet/CarpetLib/src/defs.cc') 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 const & c) return s; } +template +size_t +memoryof (map const & c) +{ + size_t s = sizeof c; + for (typename map::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 size_t memoryof (stack const & c) @@ -345,6 +358,7 @@ template size_t memoryof (set const & l); template size_t memoryof (set const & l); template size_t memoryof (set const & l); template size_t memoryof (set const & l); +template size_t memoryof (map const & l); template size_t memoryof (set const & l); template size_t memoryof (stack const & s); template size_t memoryof (vector const & v); @@ -419,6 +433,7 @@ template istream& input (istream& os, vector > >& v); //template ostream& output (ostream& os, const list& l); //template ostream& output (ostream& os, const list& l); +template ostream& output (ostream& os, const pair& p); #ifdef CARPET_ENABLE_BBOXSET2 //template ostream& output (ostream& os, const map > >& m); //template ostream& output (ostream& os, const map > >& m); -- cgit v1.2.3