void setDifference(BSONObjSetDefaultOrder &l, BSONObjSetDefaultOrder &r, vector<BSONObj*> &diff) { BSONObjSetDefaultOrder::iterator i = l.begin(); BSONObjSetDefaultOrder::iterator j = r.begin(); while ( 1 ) { if ( i == l.end() ) break; while ( j != r.end() && j->woCompare( *i ) < 0 ) j++; if ( j == r.end() || i->woCompare(*j) != 0 ) { const BSONObj *jo = &*i; diff.push_back( (BSONObj *) jo ); } i++; } }
void run() { create(); BSONObjBuilder b; b.append( "a", shortArray()) ; BSONObjSetDefaultOrder keys; id().getKeysFromObject( b.done(), keys ); checkSize( 3, keys ); int j = 1; for ( BSONObjSetDefaultOrder::iterator i = keys.begin(); i != keys.end(); ++i, ++j ) { BSONObjBuilder b; b.append( "", j ); assertEquals( b.obj(), *i ); } }
void run() { create(); vector< BSONObj > elts; for ( int i = 1; i < 4; ++i ) elts.push_back( simpleBC( i ) ); BSONObjBuilder b; b.append( "a", elts ); BSONObjSetDefaultOrder keys; id().getKeysFromObject( b.done(), keys ); checkSize( 3, keys ); int j = 1; for ( BSONObjSetDefaultOrder::iterator i = keys.begin(); i != keys.end(); ++i, ++j ) { BSONObjBuilder b; b.append( "", j ); assertEquals( b.obj(), *i ); } }