summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2010-02-09 12:20:56 -0500
committerMathias Stearn <mathias@10gen.com>2010-02-09 12:30:58 -0500
commit95fa5a3bc7e3f33dae53abe75180fba98b667f78 (patch)
tree3bd92217999dafacab1bee2c44cffd9b94f05df8
parent392d9bfe8d4ce5086768acdfe31592509f2e2df1 (diff)
downloadmongo-95fa5a3bc7e3f33dae53abe75180fba98b667f78.tar.gz
sharding: ChunkCmp STL compare functor
-rw-r--r--s/chunk.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/s/chunk.h b/s/chunk.h
index f2d04f4d3af..4d5e611322b 100644
--- a/s/chunk.h
+++ b/s/chunk.h
@@ -218,4 +218,22 @@ namespace mongo {
static unsigned long long NextSequenceNumber;
};
+ // like BSONObjCmp. for use as an STL comparison functor
+ // key-order in "order" argument must match key-order in shardkey
+ class ChunkCmp {
+ public:
+ ChunkCmp( const BSONObj &order = BSONObj() ) : _cmp( order ) {}
+ bool operator()( const Chunk &l, const Chunk &r ) const {
+ return _cmp(l.getMin(), r.getMin());
+ }
+
+ bool operator()( const Chunk *l, const Chunk *r ) const {
+ return operator()(*l, *r);
+ }
+ private:
+ BSONObjCmp _cmp;
+ };
+
+
+
} // namespace mongo