Beispiel #1
0
 DirectXShader::DirectXShader(const std::shared_ptr<DirectXRenderer>& renderer, const std::string& path, const std::string& entryPoint, ShaderType type)
     : Shader(entryPoint, type)
 {
     DataChunk data = loadData(path);
     D3DInclude includes(getCurrentDir() / path);
     compileShader(renderer, data, &includes, entryPoint, type);
 }
void Selection::toggle(SPObject *obj) {
    if (includes (obj)) {
        remove (obj);
    } else {
        add(obj);
    }
}
Beispiel #3
0
bool includes(const double a1[], int n1, const double a2[], int n2)
{
    if(n2 <= 0)   //what if n2 is negative
        return true;
    if(n1 <= 0)
        return false;
    if(a1[n1-1] == a2[n2-1])
    {
        return includes(a1, n1-1, a2, n2-1);
    }
    else
    {
        return includes(a1, n1-1, a2, n2);
    }
    
}
Beispiel #4
0
int main(int argc, char** argv)
{
	//Generator obj(4);

	std::deque<int> mydeque(5);
	std::generate(mydeque.begin(), mydeque.end(), Generator(4));

	std::ostream_iterator<int> out_it (std::cout, "; ");
    copy (mydeque.begin(), mydeque.end(), out_it);
    std::cout << std::endl;

    std::vector<int> s1(5);
    copy(mydeque.begin(), mydeque.end(), s1.begin());
    copy (s1.begin(), s1.end(), out_it);
    std::cout << std::endl;

    mydeque.clear();

    std::vector<int> s2(10);
    std::generate(s2.begin(), s2.end(), Generator(2));
    copy (s2.begin(), s2.end(), out_it);
    std::cout << std::endl;

    std::vector<int> s3;
    //generate_n 
    std::back_insert_iterator<std::vector<int> > it (s3);
    generate_n(it, 6, Generator(3));

    copy (s3.begin(), s3.end(), out_it);
    std::cout << std::endl;

    std::cout << "s1 contenu dans s2 : " << (includes(s1.begin(), s1.end(), s2.begin(), s2.end()) ? "true" : "false") << std::endl;

	return 0;
}
Beispiel #5
0
void pure_numeric_algo(){
    cout<<endl<<"pure_numeric_algo :"<<endl;
    int ia[11] = {0, 1, 2, 3, 4, 5, 6,6,6, 7, 8 };
    vector<int> iv(ia,ia+11);	vector<int> iv2(ia+6,ia+8);	vector<int>::iterator itr;
    itr = adjacent_find(iv.begin(),iv.end(), equal_to<int>());	//找到相邻元素相等的第一个元素
    cout<<"adjacent_find: "<<*itr<<endl;
    cout<<"count: "<<count(iv.begin(),iv.end(), 6)<<endl;	//找到元素值等于6的个数
    cout<<"count_if: "<<count_if(iv.begin(),iv.end(), bind2nd(less<int>() , 7))<<endl;		//找到小于7的元素个数
    itr = find(iv.begin(),iv.end(), 4);				//找到元素等于4的第一个元素位置
    cout<<"find: "<<*itr<<endl;
    itr = find_if(iv.begin(),iv.end(), bind2nd(greater<int>() , 2));				//找到元素大于2的第一个元素位置
    cout<<"find_if: "<<*itr<<endl;
    itr = find_end(iv.begin(),iv.end(), iv2.begin(),iv2.end());				//找到iv序列中最后子序列匹配出现的位置
    cout<<"find_end: "<<*(itr+3)<<endl;
    itr = find_first_of(iv.begin(),iv.end(), iv2.begin(),iv2.end());			//找到iv序列中最先子序列匹配出现的位置
    cout<<"find_end: "<<*(itr+3)<<endl;
    remove(iv.begin(),iv.end(), 6);				//删除元素,向前移,但是容器size不变,后面会剩余数据
    cout<<"remove: "<<iv<<endl;
    vector<int> iv3(12,-1);
    remove_copy(iv.begin(),iv.end(), iv3.begin(), 6);	//删除元素,将数据拷贝到新容器,后面会剩余数据
    cout<<"remove_copy: "<<iv3<<endl;
    remove_if(iv.begin(),iv.end(), bind2nd(less<int>(), 6));	//删除小于6的元素,后面会剩余数据
    cout<<"remove_if: "<<iv<<endl;
    remove_copy_if(iv.begin(),iv.end(), iv3.begin(), bind2nd(less<int>(), 7));		//删除小于7的元素,并拷贝到新容器
    cout<<"remove_copy_if: "<<iv3<<endl;
    replace(iv.begin(),iv.end(), 6, 3);			//将所有元素值为6的改为3
    cout<<"replace: "<<iv<<endl;
    replace_copy(iv.begin(),iv.end(),iv3.begin(), 3, 5);			//将所有元素值为3的改为5,结果保存在新容器中
    cout<<"replace_copy: "<<iv3<<endl;
    replace_if(iv.begin(),iv.end(), bind2nd(less<int>(),5), 2);			//将所有元素值小于5的改为2
    cout<<"replace_if: "<<iv<<endl;
    replace_copy_if(iv.begin(),iv.end(),iv3.begin(), bind2nd(equal_to<int>(),8), 9);			//将所有元素值为8的改为9,结果保存在新容器中
    cout<<"replace_copy_if: "<<iv3<<endl;
    reverse(iv.begin(),iv.end());			cout<<"reverse: "<<iv<<endl;		//反转
    reverse_copy(iv.begin(),iv.end(),iv3.begin());		cout<<"reverse_copy: "<<iv3<<endl;	//反转,结果保存在新容器
    rotate(iv.begin(),iv.begin() + 4, iv.end());	cout<<"rotate: "<<iv<<endl;			//互换元素
    rotate_copy(iv.begin(),iv.begin() + 5,iv.end(),iv3.begin());		cout<<"rotate_copy: "<<iv3<<endl;	//互换元素,结果保存在新容器
    int ia2[] = {2, 8};		vector<int> iv4(ia2,ia2+2);
    cout<<"search:  "<<*search(iv.begin(),iv.end(),iv4.begin(),iv4.end())<<endl;		//查找子序列出现的第一次出现地点
    swap_ranges(iv4.begin(),iv4.end(),iv.begin());				//按区域交换
    cout<<"swap_ranges:  "<<iv<<endl<<iv4<<endl;
    transform(iv.begin(),iv.end(),iv.begin(),bind2nd(minus<int>(), 2));		//所有元素减2
    cout<<"transform:  "<<iv<<endl;
    transform(iv4.begin(),iv4.end(),iv.begin(),iv4.begin(),plus<int>());		//区间对应元素相加
    cout<<"transform:  "<<iv4<<endl;
    /************************************************************************/
    vector<int> iv5(ia,ia+11);	vector<int> iv6(ia+4,ia+8);	vector<int> iv7(15);
    cout<<"max_element:  "<<*max_element(iv5.begin(), iv5.end())<<endl;		//最大元素游标
    cout<<"min_element:  "<<*min_element(iv5.begin(), iv5.end())<<endl;
    cout<<"includes:  "<<includes(iv5.begin(),iv5.end(),iv6.begin(),iv6.end())<<endl;	//iv6中元素是不是都在iv5中,这两个必须排过序
    merge(iv5.begin(),iv5.end(),iv6.begin(),iv6.end(),iv7.begin());	//两个排序号的容器合并
    cout<<"merge:  "<<iv7<<endl;
    partition(iv7.begin(),iv7.end(),bind2nd(equal_to<int>(), 5));	//满足条件的放在左边,不满足条件的放在右边
    cout<<"partition:  "<<iv7<<endl;
    unique(iv5.begin(),iv5.end());				//去重,重复的元素放在后面
    cout<<"unique:  "<<iv5<<endl;
    unique_copy(iv5.begin(),iv5.end(),iv7.begin());				//去重,结果保存在新容器
    cout<<"unique_copy:  "<<iv7<<endl;
}
Beispiel #6
0
bool CList::EQlist(CList* l) {
  if (this == l) return true;
  if (length() != l->length()) return false;
  for (CListElem* e = l->head(); e; e = e->next()) {
    if (! includes(e->data())) return false;
  }
  return true;
}
Beispiel #7
0
int
BinaryTree<DataType>::update(const DataType &data)
{
	if (includes(data))
		return(insert(data));
	else
		return(NOMATCH);
}
void Selection::_removeObjectAncestors(SPObject *obj) {
        SPObject *parent = obj->parent;
        while (parent) {
            if (includes(parent)) {
                _remove(parent);
            }
            parent = parent->parent;
        }
}
void Selection::remove(SPObject *obj) {
    g_return_if_fail(obj != NULL);
    g_return_if_fail(SP_IS_OBJECT(obj));
    g_return_if_fail(includes(obj));

    _invalidateCachedLists();
    _remove(obj);
    _emitChanged();
}
Beispiel #10
0
void CodeGenerator::writeIncludes()
{
	CodeGenerator::IncludeSet::const_iterator it = systemIncludes().begin();
	CodeGenerator::IncludeSet::const_iterator itEnd = systemIncludes().end();
	for (; it != itEnd; ++it)
		writeSystemInclude(*it);

	it = includes().begin();
	itEnd = includes().end();
	for (; it != itEnd; ++it)
		writeInclude(*it, true);

	it = _srcIncludes.begin();
	itEnd = _srcIncludes.end();
	for (; it != itEnd; ++it)
		writeInclude(*it, false);
	
	writeFwdDecls(_fwdDecls);
}
Beispiel #11
0
bool Rule::operator == (const Rule& _rhs) {
    if(type != _rhs.type || head != _rhs.head || body_length != _rhs.body_length)
        return false;
    else {
        if(!(body_lits.size() == _rhs.body_lits.size() && 
                includes(_rhs.body_lits.begin(), _rhs.body_lits.end(), body_lits.begin(), body_lits.end())))
            return false;
    }
    return true;
}
Beispiel #12
0
void death( char_data* victim, char_data* ch, char* dt )
{
  char               tmp  [ TWO_LINES ];
  obj_data*       corpse;
  content_array*   where  = victim->array;
  char_data*         rch;
  bool           survive;
 
  remove_bit( &victim->status, STAT_BERSERK );

  if( ch == NULL ) 
    for( int i = 0; i < *where; i++ ) 
      if( ( rch = character( where->list[i] ) ) != NULL 
        && includes( rch->aggressive, victim ) ) {
        ch = rch;
        break;
        }

  stop_fight( victim );
  clear_queue( victim );

  if( !can_die( victim ) )
    return;
 
  disburse_exp( victim );
  register_death( victim, ch, dt );

  clear_queue( victim );
  death_cry( victim );

  if( survive = !die_forever( victim ) )
    raw_kill( victim );

  corpse = make_corpse( victim, where );
  loot_corpse( corpse, ch, victim );

  if( survive ) 
    return;

  if( mob( victim ) != NULL ) {
    victim->Extract( );
    return;
    }

  sprintf( tmp, "%s's soul is taken by death.", victim->Name( ) );
  info( tmp, LEVEL_BUILDER, tmp, IFLAG_DEATHS, 1, victim );

  clear_screen( victim );
  reset_screen( victim );

  send( victim, "Death is surprisingly peaceful.\n\r" );
  send( victim, "Good night.\n\r" );

  purge( player( victim ) );
}
Beispiel #13
0
 // inc paths can be directly passed from C code
 std::string find_file(const std::string& file, const char* paths[])
 {
   if (paths == 0) return std::string("");
   std::vector<std::string> includes(0);
   // includes.push_back(".");
   const char** it = paths;
   while (it && *it) {
     includes.push_back(*it);
     ++it;
   }
   return find_file(file, includes);
 }
void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) {
    g_return_if_fail(obj != NULL);
    g_return_if_fail(SP_IS_OBJECT(obj));
    g_return_if_fail(obj->document != NULL);

    if (includes(obj)) {
        return;
    }

    _invalidateCachedLists();
    _add(obj);
    _emitChanged(persist_selection_context);
}
void Selection::addList(std::vector<SPItem*> const &list) {

    if (list.empty())
        return;

    _invalidateCachedLists();

    for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end(); ++iter) {
        SPObject *obj = *iter;
        if (includes(obj)) continue;
        _add (obj);
    }

    _emitChanged();
}
 void enter(const TTransition& transition, TArgs&&... args) const
 {
   if (transition.is_reentry())
   {
     execute_entry_actions(transition, std::forward<TArgs>(args)...);
   }
   else if (!includes(transition.source()))
   {
     if (super_state_ != nullptr)
     {
       super_state_->enter(transition, std::forward<TArgs>(args)...);
     }
     execute_entry_actions(transition, std::forward<TArgs>(args)...);
   }
 }
 void exit(const TTransition& transition) const
 {
   if (transition.is_reentry())
   {
     execute_exit_actions(transition);
   }
   else if (!includes(transition.destination()))
   {
     execute_exit_actions(transition);
     if (super_state_ != nullptr)
     {
       super_state_->exit(transition);
     }
   }
 }
Beispiel #18
0
 // tests if the columns of TSDB 'table' match the datapoint type T
 // returns false if 'table' does not have the columns necessary for required datatype
 template<typename T> bool _columns_match_type(const std::string& table)
 {
     BOOST_STATIC_ASSERT((boost::is_base_of< dp::DataPoint, T>::value));
     
     std::vector<std::string> columns = get_column_names( table );
     std::vector<std::string> t_columns = dp::dp_names<T>();
     
     std::sort(columns.begin(),columns.end());
     std::sort(t_columns.begin(),t_columns.end());
     
     if( !includes(columns.begin(), columns.end(), t_columns.begin(), t_columns.end() ) )
         return false;
     
     return true;
 }
Beispiel #19
0
int
BinaryTree<DataType>::includes(const BinaryTreeNode<DataType> *node, 
				const DataType &data) const
{
	// look for a match
	if (node == NULL)
	{
		// not found
		return(0);
	}
	else if (data < node->data)
	{
		return(includes(node->left, data));
	}
	else if (data > node->data)
	{
		return(includes(node->right, data));
	}
	else
	{
		// found
		return(1);
	}
}
Beispiel #20
0
    inline bool
    range_run<Char>::test(Char val) const
    {
        if (run.empty())
            return false;

        // search the ranges for one that potentially includes val
        typename storage_type::const_iterator iter =
            std::upper_bound(
                run.begin(), run.end(), val,
                range_compare<range_type>()
            );

        // return true if *(iter-1) includes val
        return iter != run.begin() && includes(*(--iter), val);
    }
Beispiel #21
0
  Prune::Prune(const vector<string>& p,const reader_t& r)
    :wrapped_reader_t(r),prune(p)
  {
    vector<string> all_names = tfr->names();
    for(int i=0;i<all_names.size();i++) {
      if (not includes(prune,all_names[i]))
	leaf_names.push_back(all_names[i]);
    }

    for(int i=0;i<prune.size();i++) {
      int index = find_index(all_names,prune[i]);
      if (index == -1)
	throw myexception()<<"Cannot find leaf '"<<prune[i]<<"' in sampled tree.";
      prune_index.push_back(index);
    }
  }
Beispiel #22
0
void BlockTab::findIntervals( void )
{
	vector< bool > visited( curBlockNum + 1, false );
	list< BasicBlock * > left;
	left.push_back( blockList[ 1 ] );        //entry node
	visited[ blockList[ 1 ] -> no ] = true;
	
	while ( !left.empty( ) ) { 
		Interval current;	
		current.Head( *left.begin( ) );
		bool added = true;
		while ( added == true ) {
		added = false;
		for ( list< BasicBlock * >::iterator i = left.begin( );
							i != left.end( ); ) {
//includes:check if first set includes the second set 

			if ( current.Head( ) == *i || 
				includes( current.begin( ), current.end( ), 
				( *i ) -> predecessors.begin( ), 
						(*i) -> predecessors.end())) {

				current.insert(*i);
				(*i) -> head = current.Head();
               			if ((*i) -> getTakenPtr() && 
					!visited[(*i) -> getTakenPtr() -> no]) {
					
				    visited[(*i) -> getTakenPtr() -> no] = true;
					left.push_back((*i) -> getTakenPtr());
					added = true;
				}
	       			if ((*i) -> getNTakenPtr() && 
					!visited[(*i)-> getNTakenPtr() -> no]) {
				   visited[(*i) -> getNTakenPtr() -> no] = true;
					left.push_back((*i) -> getNTakenPtr());
					added = true;
				}
				left.erase(i++); 
	       		}
			else
				i++;
		}
		}
		all.push_back(current);
	}
}
Beispiel #23
0
 void BitVector::print() {
   print_short();
   lprintf(": {");
   fint i, last = -1;
   for (i = 0; i < length; i++) {
     if (includes(i)) {
       if (last < 0) {
         lprintf(" %ld", (void*)i);    // first bit after string of 0s
         last = i;
       }
     } else {
       if (last >= 0) lprintf("..%ld", (void*)(i - 1)); // ended a group
       last = -1;
     }
   }
   if (last >= 0) lprintf("..%ld", (void*)(i - 1));
   lprintf(" }");
 }
Beispiel #24
0
Interval::uint64 CodeInterval::descale(Interval::uint64 value) const throw(not_normalized, range_error)
{
	if(!is_normalized()) {
		throw not_normalized("Interval must be normalized before descale.");
	}
	if(!includes(value)) {
		throw range_error("Value not in interval.");
	}
	
	// value = (value - base) · 2⁶⁴ / (range + 1)
	if(range == max) {
		return value - base;
	} else {
		assert(value - base < range + 1);
		std::uint64_t q, r;
		std::tie(q, r) = div128(value - base, 0, range + 1);
		q += (r >= msb) ? 1 : 0;
		return q;
	}
}
Beispiel #25
0
  void BitVector::removeFromTo(int32 first, int32 last) {
    assert(first >= 0 && first < length, "wrong index");
    assert(last >= 0 && last < length, "wrong index");
    fint startIndex = indexFromNumber(first);
    fint   endIndex = indexFromNumber(last);
    if (startIndex == endIndex) {
      assert(last - first < BitsPerWord, "oops");
      int32 mask = ~nthMask(last - first + 1);
      bits[startIndex] &= mask << offsetFromNumber(first);
    } else {
      bits[startIndex] &= ~(AllBits << offsetFromNumber(first));
      for (fint i = startIndex + 1; i < endIndex; i++) bits[i] = 0;
      bits[endIndex] &= ~nthMask(offsetFromNumber(last) + 1);
    }
#   if GENERATE_DEBUGGING_AIDS
      if (CheckAssertions)
        for (fint i = first; i <= last; i++)
          assert(!includes(i), "bit shouldn't be set");
#   endif
  }
Beispiel #26
0
bool Exit_Data :: Seen( char_data* ch )
{
  wizard_data* imm;

  if( !is_set( &exit_info, EX_CLOSED ) ) 
    return TRUE;

  if( ( imm = wizard( ch ) ) != NULL
    && is_set( ch->pcdata->pfile->flags, PLR_HOLYLIGHT ) )
    return TRUE;

  if( is_set( &exit_info, EX_NO_SHOW ) )
    return FALSE;
 
  if( is_set( &exit_info, EX_SECRET ) 
    && !includes( ch->seen_exits, this ) ) 
    return FALSE;

  return TRUE;
}
Beispiel #27
0
    void
    range_run<Char>::set(range_type const& range)
    {
        BOOST_ASSERT(is_valid(range));
        if (run.empty())
        {
            // the vector is empty, insert 'range'
            run.push_back(range);
            return;
        }

        // search the ranges for one that potentially includes 'range'
        typename storage_type::iterator iter =
            std::upper_bound(
                run.begin(), run.end(), range,
                range_compare<range_type>()
            );

        if (iter != run.begin())
        {
            // if *(iter-1) includes 'range', return early
            if (includes(*(iter-1), range))
            {
                return;
            }

            // if *(iter-1) can merge with 'range', merge them and return
            if (try_merge(run, iter-1, range))
            {
                return;
            }
        }

        // if *iter can merge with with 'range', merge them
        if (iter == run.end() || !try_merge(run, iter, range))
        {
            // no overlap, insert 'range'
            run.insert(iter, range);
        }
    }
Beispiel #28
0
CollOfCell EquelleRuntimeCPU::inputDomainSubsetOf(const String& name,
                                                  const CollOfCell& cell_superset)
{
    const String filename = param_.get<String>(name + "_filename");
    std::ifstream is(filename.c_str());
    if (!is) {
        OPM_THROW(std::runtime_error, "Could not find file " << filename);
    }
    std::istream_iterator<int> beg(is);
    std::istream_iterator<int> end;
    CollOfCell data;
    for (auto it = beg; it != end; ++it) {
        data.push_back(Cell(*it));
    }
    if (!is_sorted(data.begin(), data.end())) {
        OPM_THROW(std::runtime_error, "Input set of cells was not sorted in ascending order.");
    }
    if (!includes(cell_superset.begin(), cell_superset.end(), data.begin(), data.end())) {
        OPM_THROW(std::runtime_error, "Given cells are not in the assumed subset.");
    }
    return data;
}
Beispiel #29
0
 forceinline ExecStatus
 Sequence<View,Val>::check(Space& home, ViewArray<View>& x, Val s, int q, int l, int u) {
   Region r(home);
   // could do this with an array of length q...
   int* upper = r.alloc<int>(x.size()+1);
   int* lower = r.alloc<int>(x.size()+1);
   upper[0] = 0;
   lower[0] = 0;
   for ( int j=0; j<x.size(); j++ ) {
     upper[j+1] = upper[j];
     lower[j+1] = lower[j];
     if (includes(x[j],s)) {
       upper[j+1] += 1;
     } else if (excludes(x[j],s)) {
       lower[j+1] += 1;
     }
     if ( j+1 >= q && (q - l < lower[j+1] - lower[j+1-q] || upper[j+1] - upper[j+1-q] > u) ) {
       return ES_FAILED;
     }
   }
   return ES_OK;
 }
Beispiel #30
0
unsigned int Scopa::playCard(Who player, Card card, capture capt) {
    if(currentTurn != player) { throw exception(exception::WRONG_TURN); }
    if(!hand[player].mem(card)) { throw exception(exception::CARD_NOT_FOUND); }
    if(!includes(table,capt.begin(),capt.end())) { throw exception(exception::NOT_A_VALID_CAPTURE); }
    
    unsigned int pointsEarned = 0;
    
    if(capt.empty()) {
        // hand -> table
        move(hand[player],table,card);
    }
    else {
        lastCapturePlayer = player;
        // hand -> capturedPile
        move(hand[player],capturedPile[player],card);
        if(Scopa::isPointCard(card)) {
            pointsEarned++;
            pointsMatch[player]++;
        }
        // table -> capturedPile
        for(capture::iterator it = capt.begin(); it != capt.end(); it++) {
            move(table,capturedPile[player],*it);
            if(Scopa::isPointCard(*it)) {
                pointsEarned++;
                pointsMatch[player]++;
            }
        }
        // is scopa?
        if(table.empty()) {
            pointsEarned++;
            pointsMatch[player]++;
        }
    }
    
    swapTurn();
    return pointsEarned;
}