]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
hobject_t: sort by (max, hash, oid, snap)
authorSage Weil <sage.weil@dreamhost.com>
Fri, 2 Dec 2011 04:57:09 +0000 (20:57 -0800)
committerSamuel Just <samuel.just@dreamhost.com>
Wed, 7 Dec 2011 19:40:10 +0000 (11:40 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/include/object.h

index 4b044d6db1b3b53688152d5aaafff63c5f98e20c..c7884711e6e26e2ac7a0f78255bd8b2ab1f415e3 100644 (file)
@@ -330,6 +330,7 @@ public:
   }
 };
 WRITE_CLASS_ENCODER(hobject_t)
+
 namespace __gnu_cxx {
   template<> struct hash<hobject_t> {
     size_t operator()(const sobject_t &r) const {
@@ -340,6 +341,39 @@ namespace __gnu_cxx {
   };
 }
 
+// sort hobject_t's by <hash,name,snapid>
+inline bool operator==(const hobject_t &l, const hobject_t &r) {
+  return l.oid == r.oid && l.snap == r.snap && l.hash == r.hash && l.max == r.max;
+}
+inline bool operator!=(const hobject_t &l, const hobject_t &r) {
+  return l.oid != r.oid || l.snap != r.snap || l.hash != r.hash || l.max != r.max;
+}
+inline bool operator>(const hobject_t &l, const hobject_t &r) {
+  return l.max > r.max ||
+    (l.max == r.max && (l.hash > r.hash ||
+                       (l.hash == r.hash && (l.oid > r.oid || 
+                                             (l.oid == r.oid && l.snap > r.snap)))));
+}
+inline bool operator<(const hobject_t &l, const hobject_t &r) {
+  return l.max < r.max ||
+    (l.max == r.max && (l.hash < r.hash ||
+                       (l.hash == r.hash && (l.oid < r.oid ||
+                                             (l.oid == r.oid && l.snap < r.snap)))));
+}
+inline bool operator>=(const hobject_t &l, const hobject_t &r) {
+  return l.max > r.max ||
+    (l.max == r.max && (l.hash > r.hash ||
+                       (l.hash == r.hash && (l.oid > r.oid ||
+                                             (l.oid == r.oid && l.snap >= r.snap)))));
+}
+inline bool operator<=(const hobject_t &l, const hobject_t &r) {
+  return l.max < r.max ||
+    (l.max == r.max && (l.hash < r.hash ||
+                       (l.hash == r.hash && (l.oid < r.oid ||
+                                             (l.oid == r.oid && l.snap <= r.snap)))));
+}
+
+
 // ---------------------------
 
 #endif