Exemple #1
0
inline bool lexicographical_equal(const SetType& left, const SetType& right)
{
    if(&left == &right)
        return true;
    else return left.iterative_size() == right.iterative_size()
             && std::equal(left.begin(), left.end(), right.begin()); 
}
void buildSetNames(const SetType & setData,std::vector<std::string> & names)
{
   // pull out all names for this set
   for(typename SetType::const_iterator itr=setData.begin();itr!=setData.end();++itr) {
      Ioss::GroupingEntity * entity = *itr;
      names.push_back(entity->name());
   }
}
Exemple #3
0
void GMStandard::multiply ( const SetType & rowSet, const SetType & columnSet, NICE::Vector & y, const NICE::Vector & x) const
{
  if ( x.size() != columnSet.size() ) 
    fthrow(Exception, "Size of the column set is different from the size of the given input vector: " << columnSet.size() << " vs " << x.size());
  
  y.resize( rowSet.size() );

  // memory inefficient
  Matrix Asub ( rowSet.size(), columnSet.size() );

  int ii = 0;
  for ( SetType::const_iterator i = rowSet.begin(); i != rowSet.end(); i++,ii++ )
  {
    int jj = 0;
    for ( SetType::const_iterator j = columnSet.begin(); j != columnSet.end(); j++,jj++ )
      Asub ( ii, jj ) = A( *i, *j ); 
  }

  y.multiply ( Asub, x );
}
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;
}
Exemple #5
0
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;    
}
Exemple #6
0
// 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" );
	}
}
Exemple #7
0
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;
}
Exemple #8
0
// 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();
}
Exemple #9
0
  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")
}