From: Sage Weil Date: Thu, 23 Jul 2015 20:23:14 +0000 (-0400) Subject: hobject_t: conditional Comparator object X-Git-Tag: v9.1.0~346^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=49539ab846e3d02807faa980c7c97098c28f6c2c;p=ceph.git hobject_t: conditional Comparator object This one can go either bitwise or nibblewise, depending on what you give pass to the STL container constructor. E.g., map mymap(hobject_t::Comparator(bitwise)); Signed-off-by: Sage Weil --- diff --git a/src/common/hobject.h b/src/common/hobject.h index d1d9c02abac0..01f0f2dc10e3 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -273,6 +273,17 @@ public: return cmp_bitwise(l, r) < 0; } }; + + struct Comparator { + bool bitwise; + Comparator(bool b) : bitwise(b) {} + bool operator()(const hobject_t& l, const hobject_t& r) const { + if (bitwise) + return cmp_bitwise(l, r) < 0; + else + return cmp_nibblewise(l, r) < 0; + } + }; }; WRITE_CLASS_ENCODER(hobject_t) @@ -428,6 +439,17 @@ public: return cmp_bitwise(l, r) < 0; } }; + + struct Comparator { + bool bitwise; + Comparator(bool b) : bitwise(b) {} + bool operator()(const ghobject_t& l, const ghobject_t& r) const { + if (bitwise) + return cmp_bitwise(l, r) < 0; + else + return cmp_nibblewise(l, r) < 0; + } + }; }; WRITE_CLASS_ENCODER(ghobject_t)