bool ULoadGroupInfo::IsLevelInLoadGroup(FName level, ELoadGroups lg) { MapType::iterator it = LoadGroups.find(lg); if ( it == LoadGroups.end() ) { return false; } SetType map = it->second; SetType::iterator it2 = map.find(level); if ( it2 == map.end() ) { return false; } return true; }
bool intersects(const SetType& left, const SetType& right) { typename SetType::const_iterator common_lwb_right_, common_upb_right_; if(!common_range(common_lwb_right_, common_upb_right_, right, left)) return false; typename SetType::const_iterator right_ = common_lwb_right_, found_; while(right_ != common_upb_right_) { found_ = left.find(*right_++); if(found_ != left.end()) return true; // found a common element } // found no common element return false; }
// if we ghave already fetched the rows because we recieved a // size message, return one of those rows. otherwise try to // get a unique row anf fail noisily if that seems not possible Row DSUnique :: Get() { if ( mPos >= 0 ) { Row r = mRows[ mPos++]; mPos %= mRows.size(); return Order( r ); } else { int n = mRetry; while( n-- ) { Row r = CompositeDataSource::Get(); if ( mUniqueRows.find( r ) == mUniqueRows.end() ) { mUniqueRows.insert( r ); return Order( r ); } } throw Exception( "cannot find enough unique values" ); } }
inline bool within(const SetType& sub, const SetType& super) { if(&super == &sub) return true; if(icl::is_empty(sub)) return true; if(icl::is_empty(super)) return false; typename SetType::const_iterator common_lwb_, common_upb_; if(!common_range(common_lwb_, common_upb_, sub, super)) return false; typename SetType::const_iterator sub_ = common_lwb_, super_; while(sub_ != common_upb_) { super_ = super.find(*sub_++); if(super_ == super.end()) return false; } return true; }
// if we receive size message read rows from kids discarding dupes // and use those rows to fufill future requests int DSUnique :: Size() { if ( mPos >= 0 ) { // already have size return mRows.size(); } int n = CompositeDataSource::Size(); while( n-- ) { Row r = CompositeDataSource::Get(); if ( mUniqueRows.find( r ) == mUniqueRows.end() ) { mUniqueRows.insert( r ); mRows.push_back( r ); } } //ALib::Dump( std::cout, mRows ); mPos = 0; if ( mRows.size() == 0 ) { throw Exception( "Empty result set" ); } return mRows.size(); }
"Hello World \xd1\x80\xd1\x88\xd0\xbd\xd1\x83")); LOG_FREE(Info, "Compare", "Leaving istringEqualMixed") } TEST(Compare, IstringCompare) { LOG_FREE(Info, "Compare", "Entering IstringEqual") // make sure insensitive string compare functor works for sets typedef std::set<string, IstringCompare> SetType; SetType words; words.insert("lorem ipsum"); auto it = words.find("lorem ipsum"); ASSERT_TRUE(words.end() != it); auto it2 = words.find("LOREM IPSUM"); EXPECT_TRUE(it == it2); it2 = words.find("lOrEm IpsUm"); EXPECT_TRUE(it == it2); it2 = words.find("LoReM iPSuM"); EXPECT_TRUE(it == it2); it2 = words.find("dolor sit amet"); EXPECT_TRUE(words.end() == it2); LOG_FREE(Info, "Compare", "Leaving IstringEqual")
"Hello World \xd1\x80\xd1\x88\xd0\xbd\xd1\x83")); LOG_FREE(Info, "Compare", "Leaving istringEqualMixed") } TEST(Compare, IstringCompare) { LOG_FREE(Info, "Compare", "Entering IstringEqual") // make sure insensitive string compare functor works for sets typedef std::set<string, IstringCompare> SetType; SetType words; words.insert("lorem ipsum"); SetType::const_iterator it = words.find("lorem ipsum"); ASSERT_TRUE(words.end() != it); SetType::const_iterator it2 = words.find("LOREM IPSUM"); EXPECT_TRUE(it == it2); it2 = words.find("lOrEm IpsUm"); EXPECT_TRUE(it == it2); it2 = words.find("LoReM iPSuM"); EXPECT_TRUE(it == it2); it2 = words.find("dolor sit amet"); EXPECT_TRUE(words.end() == it2); LOG_FREE(Info, "Compare", "Leaving IstringEqual")