diff options
author | Dwight <dmerriman@gmail.com> | 2008-06-08 10:58:19 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2008-06-08 10:58:19 -0400 |
commit | 5080d260b01f51dbf083245729763fedc9f5e8b8 (patch) | |
tree | c46ec0acf3cc609222bcd20cb588c0ec1b996d70 /util | |
parent | 3ac43db818cff02d923383f13e07e4b4029b4d8a (diff) | |
download | mongo-5080d260b01f51dbf083245729763fedc9f5e8b8.tar.gz |
horrific cursor code gone
Diffstat (limited to 'util')
-rw-r--r-- | util/goodies.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/util/goodies.h b/util/goodies.h index 94ca721aa8b..af6fd3f20b0 100644 --- a/util/goodies.h +++ b/util/goodies.h @@ -13,6 +13,20 @@ inline pthread_t GetCurrentThreadId() { return pthread_self(); } /* set to TRUE if we are exiting */ extern bool goingAway; +/* find the multimap member which matches a particular key and value. + + note this can be slow if there are a lot with the same key. +*/ +template<class C,class K,class V> inline typename C::iterator kv_find(C& c, const K& k,const V& v) { + pair<typename C::iterator,typename C::iterator> p = c.equal_range(k); +
+ for( typename C::iterator it=p.first; it!=p.second; ++it)
+ if( it->second == v )
+ return it;
+
+ return c.end();
+} + bool isPrime(int n); int nextPrime(int n); |