From 0799760700c288939bc39ad43f3e167d42406df5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 Nov 2010 10:18:09 +0200 Subject: Add support for unordered storage of ordered containers New pragma: unordered. --- common/container/driver.cxx | 12 ++++++++++++ common/container/test.hxx | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'common/container') diff --git a/common/container/driver.cxx b/common/container/driver.cxx index 8355ab1..9940c9a 100644 --- a/common/container/driver.cxx +++ b/common/container/driver.cxx @@ -57,6 +57,9 @@ main (int argc, char* argv[]) med.cv.push_back (comp (123, "aaa")); med.cv.push_back (comp (234, "bbbb")); + med.uv.push_back (123); + med.uv.push_back (234); + // list // med.sl.push_back ("aaa"); @@ -108,6 +111,10 @@ main (int argc, char* argv[]) full.cv.push_back (comp (2345, "bbbbb")); full.cv.push_back (comp (3456, "cccccc")); + full.uv.push_back (1234); + full.uv.push_back (2345); + full.uv.push_back (3456); + // list // full.sl.push_back ("aaaa"); @@ -179,6 +186,7 @@ main (int argc, char* argv[]) empty.nv.push_back (12); empty.sv.push_back ("aa"); empty.cv.push_back (comp (12, "aa")); + empty.uv.push_back (12); empty.sl.push_back ("aa"); empty.ns.insert (12); empty.ss.insert ("aa"); @@ -198,6 +206,7 @@ main (int argc, char* argv[]) med.nv.clear (); med.sv.clear (); med.cv.clear (); + med.uv.clear (); med.sl.clear (); @@ -229,6 +238,9 @@ main (int argc, char* argv[]) full.cv.back ().str += "c"; full.cv.push_back (comp (4567, "ddddddd")); + full.uv.back ()++; + full.uv.push_back (4567); + // list // full.sl.back () += "c"; diff --git a/common/container/test.hxx b/common/container/test.hxx index a12be5c..1f565cd 100644 --- a/common/container/test.hxx +++ b/common/container/test.hxx @@ -10,7 +10,6 @@ #include #include #include - #include #include @@ -96,6 +95,9 @@ struct object #pragma db value_column("") comp_vector cv; + #pragma db unordered + num_vector uv; + // list // #pragma db transient @@ -120,6 +122,17 @@ struct object inline bool operator== (const object& x, const object& y) { + if (x.uv.size () != y.uv.size ()) + return false; + + int xs (0), ys (0); + + for (num_vector::size_type i (0); i < x.uv.size (); ++i) + { + xs += x.uv[i]; + ys += y.uv[i]; + } + return x.id_ == y.id_ && x.num == y.num && @@ -130,6 +143,7 @@ operator== (const object& x, const object& y) x.nv == y.nv && x.sv == y.sv && x.cv == y.cv && + xs == ys && x.sl == y.sl && -- cgit v1.1