Exemple #1
0
Node* List::search(bool (*condition)(const void* el)) {
	Node *tmp = head, *result = 0;
	while(tmp){
		if (condition(tmp)) {
			result = tmp;
			break;
		}
		tmp = tmp->next;
	}
	return result;
}
_Use_decl_annotations_
OVS_FXARRAY_ITEM* FXArray_Find_Unsafe(const OVS_FIXED_SIZED_ARRAY* pArray, FXArrayCondition condition, const VOID* pCondData)
{
    OVS_FXARRAY_ITEM* pOutItem = NULL;

    OVS_FXARRAY_FOR_EACH(pArray, pCurItem, /*if*/ condition(pCurItem, (UINT_PTR)pCondData),
        pOutItem = OVS_REFCOUNT_REFERENCE(pCurItem)
        );

    return pOutItem;
}
dds::core::cond::TCondition<org::opensplice::core::cond::ConditionDelegate>
org::opensplice::core::cond::ConditionDelegate::wrapper()
{
    ISOCPP_REPORT_STACK_DELEGATE_BEGIN(this);

    org::opensplice::core::cond::ConditionDelegate::ref_type ref =
            OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<ConditionDelegate>(this->get_strong_ref());
    dds::core::cond::TCondition<org::opensplice::core::cond::ConditionDelegate> condition(ref);

    return condition;
}
Exemple #4
0
void condition(int a, int b){
	
		 int i;
    if(x[a][b]==0){
		 for(i=1;i<=9;i++){
		 	if(check_legal(a,b,i)){
		 		x[a][b] = i;
		 		if(a==8 && b==8){
		 			print_x();
		 			total++;
                    return;
		 		}
		 		else{
		 			if(b==8){
		 				condition(a+1,0);
		 			}
		 			else{
		 				condition(a,b+1);
		 			}
		 		}
		 		x[a][b]=0;
		 	}
		 }
	}
	else{
		if(a==8&&b==8){
			print_x();
			total++;
			return;
		}
		else if(b==8){
		 	condition(a+1,0);
		}
		else{
		 	condition(a,b+1);
		}
	}

    return ;
	
}
Exemple #5
0
void *r_cmemcpy(int8_t *dest, int8_t *src, size_t n, int32_t (*condition)(void *))
{
	int32_t i;
        int32_t j = 0;
        for(i = 0; i <= n; i ++) {
                if(condition(src)) {
                        dest[j ++] = src[i];
                }
        }
        dest[j ++] = 0;
	return dest;
}
void backtrack(int *weight,int *value,int *answer,int step){
	if(step==N)
		display_outcome(answer,weight,value);
	else{
		int i;
		for(i=0;i<2;i++)
			if(condition(weight,answer,step,i)){
				answer[step]=i;
				backtrack(weight,value,answer,step+1);
			}
	}
}
Exemple #7
0
string BreakPoint::symbol() const
{
    char c;
    if (!enabled())
	c = '_';
    else if (!condition().empty() || ignore_count() != 0)
	c = '?';
    else
	c = '#';

    return c + itostring(number()) + c;
}
Exemple #8
0
int main()
{
	f = fopen("s1.dat","r");
	int row, column;
					
	scan();	
	int i,j;


	condition(0,0);
	printf("\n\n total = %d\n\n",total);
	return 0;
}
Exemple #9
0
void MiscThreadTestCase::TestThreadConditions()
{
    wxMutex mutex;
    wxCondition condition(mutex);

    // otherwise its difficult to understand which log messages pertain to
    // which condition
    //wxLogTrace(wxT("thread"), wxT("Local condition var is %08x, gs_cond = %08x"),
    //           condition.GetId(), gs_cond.GetId());

    // create and launch threads
    MyWaitingThread *threads[10];

    size_t n;
    for ( n = 0; n < WXSIZEOF(threads); n++ )
    {
        threads[n] = new MyWaitingThread( &mutex, &condition );
    }

    for ( n = 0; n < WXSIZEOF(threads); n++ )
    {
        CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, threads[n]->Run() );
    }

    // wait until all threads run
    // NOTE: main thread is waiting for the other threads to start
    size_t nRunning = 0;
    while ( nRunning < WXSIZEOF(threads) )
    {
        CPPUNIT_ASSERT_EQUAL( wxSEMA_NO_ERROR, gs_cond.Wait() );

        nRunning++;

        // note that main thread is already running
    }

    wxMilliSleep(500);

#if 1
    // now wake one of them up
    CPPUNIT_ASSERT_EQUAL( wxCOND_NO_ERROR, condition.Signal() );
#endif

    wxMilliSleep(200);

    // wake all the (remaining) threads up, so that they can exit
    CPPUNIT_ASSERT_EQUAL( wxCOND_NO_ERROR, condition.Broadcast() );

    // give them time to terminate (dirty!)
    wxMilliSleep(500);
}
Exemple #10
0
void ExMysqlColumn::add_condition(const char* type,
                                  const char* operation,
                                  const int value)
{
    if(type == NULL)
    {
        LOGD("[GWJ] %s: [condition type] NULL ERROR!! ", __FUNCTION__);
        return;
    }

    WhereCondition condition(type, operation);
    condition.set_value(value);
    this->where_condition.push_back(condition);
}
/* analisa e traduz um REPEAT-UNTIL*/
void doRepeat()
{
	int l1, l2;

	match('r');
	l1 = newLabel();
        l2 = newLabel();
	postLabel(l1);
	block(l2);
	match('u');
	condition();
	emit("JZ L%d", l1);
	postLabel(l2);
}
void backtrack(int *set,int *answer,int target,int step){
	if(step==N){
		if(getsizeok(answer,target))
			display_outcome(answer,set);
	}else{
		int i;
		for(i=0;i<2;i++){
			if(condition(answer,target,step,i)<=target){
				answer[step]=i;
				backtrack(set,answer,target,step+1);
			}
		}
	}
}
Exemple #13
0
void CachedNode::Debug::print() const
{
    CachedNode* b = base();
    char scratch[256];
    size_t index = snprintf(scratch, sizeof(scratch), "// char* mExport=\"");
    const UChar* ch = b->mExport.characters();
    while (ch && *ch && index < sizeof(scratch)) {
        UChar c = *ch++;
        if (c < ' ' || c >= 0x7f) c = ' ';
        scratch[index++] = c;
    }
    DUMP_NAV_LOGD("%.*s\"\n", index, scratch);
    DEBUG_PRINT_RECT(mBounds);
    DEBUG_PRINT_RECT(mHitBounds);
    DEBUG_PRINT_RECT(mOriginalAbsoluteBounds);
    const WTF::Vector<WebCore::IntRect>* rects = &b->mCursorRing;
    size_t size = rects->size();
    DUMP_NAV_LOGD("// IntRect cursorRings={ // size=%d\n", size);
    for (size_t i = 0; i < size; i++) {
        const WebCore::IntRect& rect = (*rects)[i];
        DUMP_NAV_LOGD("    // {%d, %d, %d, %d}, // %d\n", rect.x(), rect.y(),
            rect.width(), rect.height(), i);
    }
    DUMP_NAV_LOGD("// };\n");
    DUMP_NAV_LOGD("// void* mNode=%p; // (%d) \n", b->mNode, mNodeIndex);
    DUMP_NAV_LOGD("// void* mParentGroup=%p; // (%d) \n", b->mParentGroup, mParentGroupIndex);
    DUMP_NAV_LOGD("// int mDataIndex=%d;\n", b->mDataIndex);
    DUMP_NAV_LOGD("// int mIndex=%d;\n", b->mIndex);
    DUMP_NAV_LOGD("// int mNavableRects=%d;\n", b->mNavableRects);
    DUMP_NAV_LOGD("// int mParentIndex=%d;\n", b->mParentIndex);
    DUMP_NAV_LOGD("// int mTabIndex=%d;\n", b->mTabIndex);
    DUMP_NAV_LOGD("// Condition mCondition=%s;\n", condition(b->mCondition));
    DUMP_NAV_LOGD("// Type mType=%s;\n", type(b->mType));
    DEBUG_PRINT_BOOL(mClippedOut);
    DEBUG_PRINT_BOOL(mDisabled);
    DEBUG_PRINT_BOOL(mFixedUpCursorRects);
    DEBUG_PRINT_BOOL(mHasCursorRing);
    DEBUG_PRINT_BOOL(mHasMouseOver);
    DEBUG_PRINT_BOOL(mIsCursor);
    DEBUG_PRINT_BOOL(mIsFocus);
    DEBUG_PRINT_BOOL(mIsHidden);
    DEBUG_PRINT_BOOL(mIsInLayer);
    DEBUG_PRINT_BOOL(mIsParentAnchor);
    DEBUG_PRINT_BOOL(mIsTransparent);
    DEBUG_PRINT_BOOL(mIsUnclipped);
    DEBUG_PRINT_BOOL(mLast);
    DEBUG_PRINT_BOOL(mUseBounds);
    DEBUG_PRINT_BOOL(mUseHitBounds);
    DUMP_NAV_LOGD("\n");
}
Exemple #14
0
int Moore_ngbh(generation_t *net, int i, int j) {
	int a, b, result = 0;
	for (a = i - 1; a <= i + 1; a++) {
		if (a < 0 || a >= net->rows)
			continue;
		for (b = j - 1; b <= j + 1; b++) {
			if ((a == i && b == j) || b < 0 || b >= net->cols)
				continue;
			if (condition(cell(net,a,b)) == ALIVE)
				result++;
		}
	}
	return result;
}
template<class HitTestCondition> TextureMapperLayer* TextureMapperLayer::hitTest(const FloatPoint& point, HitTestCondition condition)
{
    if (!m_state.visible || !m_state.contentsVisible)
        return 0;

    TextureMapperLayer* result = 0;
    for (int i = m_children.size() - 1; !result && i >= 0; --i)
        result = m_children[i]->hitTest(point, condition);

    if (result)
        return result;

    return condition(this, point) ? this : 0;
}
ssize_t SharedBufferClient::numOfAvailableBuffer(bool lock)
{
    SharedBufferStack& stack( *mSharedStack );  
    
    if(lock)
    {
        BufferAllFreeCondition condition(this);
        status_t err = waitForCondition(condition);
        if (err != NO_ERROR)
            return 0;    
    }
     
    return stack.numofbuffer;
}
 relation_mutator_fn * external_relation_plugin::mk_filter_equal_fn(const relation_base & r, 
     const relation_element & value, unsigned col) {
     if(!check_kind(r)) {
         return 0;
     }
     ast_manager& m = get_ast_manager();
     app_ref condition(m);
     expr_ref var(m);
     sort* relation_sort = get(r).get_sort();
     sort* column_sort = get_column_sort(col, relation_sort);
     var = m.mk_var(col, column_sort);
     condition = m.mk_eq(var, value);
     return mk_filter_interpreted_fn(r, condition);
 }
pcl::ConditionOr<pcl::PointXYZ>::Ptr conditionbox(line linen){
    // Checks available: GT, GE, LT, LE, EQ.
pcl::ConditionOr<pcl::PointXYZ>::Ptr condition(new pcl::ConditionOr<pcl::PointXYZ>());
float xmin = std::min(linen.x0,linen.x1)-pose.x.stddev*a-b-pose.x.mean-pose.theta.stddev*c;
float xmax = std::max(linen.x0,linen.x1)+pose.x.stddev*a+b-pose.x.mean+pose.theta.stddev*c;
float ymin = std::min(-linen.y0,-linen.y1)-pose.y.stddev*a-b+pose.y.mean-pose.theta.stddev*c;
float ymax = std::max(-linen.y0,-linen.y1)+pose.y.stddev*a+b+pose.y.mean+pose.theta.stddev*c;
condition->addComparison(pcl::FieldComparison<pcl::PointXYZ>::ConstPtr(new pcl::FieldComparison<pcl::PointXYZ>("z", pcl::ComparisonOps::LT, xmin)));
condition->addComparison(pcl::FieldComparison<pcl::PointXYZ>::ConstPtr(new pcl::FieldComparison<pcl::PointXYZ>("z", pcl::ComparisonOps::GT, xmax)));
condition->addComparison(pcl::FieldComparison<pcl::PointXYZ>::ConstPtr(new pcl::FieldComparison<pcl::PointXYZ>("x", pcl::ComparisonOps::LT, ymin)));
condition->addComparison(pcl::FieldComparison<pcl::PointXYZ>::ConstPtr(new pcl::FieldComparison<pcl::PointXYZ>("x", pcl::ComparisonOps::GT, ymax)));
//std::cout << xmin << " " << xmax << " " << ymin << " " << ymax << std::endl;
 return condition;
}
Exemple #19
0
void CachedNode::Debug::print() const
{
    CachedNode* b = base();
    char scratch[256];
    size_t index = snprintf(scratch, sizeof(scratch), "// char* mExport=\"");
    const UChar* ch = b->mExport.characters();
    while (ch && *ch && index < sizeof(scratch))
        scratch[index++] = *ch++;
    DUMP_NAV_LOGD("%.*s\"\n", index, scratch);
    index = snprintf(scratch, sizeof(scratch), "// char* mName=\"");
    ch = b->mName.characters();
    while (ch && *ch && index < sizeof(scratch))
        scratch[index++] = *ch++;
    DUMP_NAV_LOGD("%.*s\"\n", index, scratch);
    DEBUG_PRINT_RECT(mBounds);
    const WTF::Vector<WebCore::IntRect>& rects = b->focusRings();
    size_t size = rects.size();
    DUMP_NAV_LOGD("// IntRect focusRings={ // size=%d\n", size);
    for (size_t i = 0; i < size; i++)
        DUMP_NAV_LOGD("    // {%d, %d, %d, %d}, // %d\n", rects[i].x(), rects[i].y(),
            rects[i].width(), rects[i].height(), i);
    DUMP_NAV_LOGD("// };\n");
    DUMP_NAV_LOGD("// void* mNode=%p; // (%d) \n", b->mNode, mNodeIndex);
    DUMP_NAV_LOGD("// void* mParentGroup=%p; // (%d) \n", b->mParentGroup, mParentGroupIndex);
    DUMP_NAV_LOGD("// int mChildFrameIndex=%d;\n", b->mChildFrameIndex);
    DUMP_NAV_LOGD("// int mIndex=%d;\n", b->mIndex);
    DUMP_NAV_LOGD("// int mMaxLength=%d;\n", b->mMaxLength);
    DUMP_NAV_LOGD("// int mNavableRects=%d;\n", b->mNavableRects);
    DUMP_NAV_LOGD("// int mParentIndex=%d;\n", b->mParentIndex);
    DUMP_NAV_LOGD("// int mTextSize=%d;\n", b->mTextSize);
    DUMP_NAV_LOGD("// Condition mCondition=%s;\n", condition(b->mCondition));
    DUMP_NAV_LOGD("// Type mType=%s;\n", type(b->mType));
    DEBUG_PRINT_BOOL(mClippedOut);
    DEBUG_PRINT_BOOL(mDisabled);
    DEBUG_PRINT_BOOL(mFixedUpFocusRects);
    DEBUG_PRINT_BOOL(mHasMouseOver);
    DEBUG_PRINT_BOOL(mIsAnchor);
    DEBUG_PRINT_BOOL(mIsArea);
    DEBUG_PRINT_BOOL(mIsFocus);
    DEBUG_PRINT_BOOL(mIsInput);
    DEBUG_PRINT_BOOL(mIsParentAnchor);
    DEBUG_PRINT_BOOL(mIsPassword);
    DEBUG_PRINT_BOOL(mIsTextArea);
    DEBUG_PRINT_BOOL(mIsTextField);
    DEBUG_PRINT_BOOL(mIsTransparent);
    DEBUG_PRINT_BOOL(mIsUnclipped);
    DEBUG_PRINT_BOOL(mLast);
    DUMP_NAV_LOGD("\n");
}
//Redefinición de método para buscar dentro de una lista por nombre
t_link_element* list_find_by_id_char(t_list *self, char* ID, bool(*condition)(void*, int), int* index) {
	t_link_element *element = self->head;
	int position = 0;

	while (element != NULL && !condition(element->data, ID)) {
		element = element->next;
		position++;
	}

	if (index != NULL) {
		*index = position;
	}

	return element;
}
Exemple #21
0
Ast::Condition* Parser::condition()
{
    Ast::Condition* left = condition_term();
    ++current;
    if(current->type != TokenType::Operator) {
        --current;
        return left;
    }
    const char op = current->getValue<char>();
    if(op != '&' && op != '|') {
        --current;
        return left;
    }
    return new Ast::Condition(left, condition(), op);
}
Exemple #22
0
int		animation_monster(t_character *self, t_animation *anim)
{
    int		tmp;

    if (self->wait == 0)
    {
        if (condition(self, anim) == SUCCESS)
            do_anim(self, anim);
        else
        {
            self->status = ((self->status == LEFT) ? (RIGHT) : (LEFT));
            if (condition(self, anim) == SUCCESS)
                do_anim(self, anim);
        }
    }
    else
    {
        tmp = self->status;
        do_anim(self, anim);
        self->status = tmp;
        self->wait--;
    }
    return (SUCCESS);
}
Exemple #23
0
static t_link_element* list_find_element(t_list *self, bool(*condition)(void*), int* index) {
	t_link_element *element = self->head;
	int position = 0;

	while (element != NULL && !condition(element->data)) {
		element = element->next;
		position++;
	}

	if (index != NULL) {
		*index = position;
	}

	return element;
}
/* analisa e traduz um comando WHILE */
void doWhile()
{
	int l1, l2;

	match('w');
	l1 = newLabel();
	l2 = newLabel();
	postLabel(l1);
	condition();
	emit("JZ L%d", l2);
	block(l2);
	match('e');
	emit("JMP L%d", l1);
	postLabel(l2);
}
void ESURegistrationTableManager::updateRecord(const QHostAddress &address, const RegistrationUserInfo &data)
{
    for(int i=0; i<m_tableData.size(); i++ ) {
        if( m_tableData[i].address == address ) {
            if( m_dbReady ) {
                QVariantMap record = __createDBRecord(data);
                QString condition("address=\'%1\'");
                condition = condition.arg(address.toString());
                if( m_dbTable->updateRecord( record, condition ) )
                    Q_EMIT contentUpdated();
            }
            break;
        }
    }
}
	inline int HeterogeneousVolume::check(const Ray &inRay, float *intersectDist) const{
		bool contactIsVol = inRay.contactObj && inRay.contactObj == this;
		if(!checkIn(inRay.origin, objID) && !contactIsVol){
			return 1;
		}
		NoSelfCondition condition(scene, inRay);
		Scene::ObjSourceInfo info;
		float d = scene->intersect(inRay, info, &condition);
		if(!(d > 0)){
			return 2;
		}
		if(intersectDist)
			*intersectDist = d;
		return 0;
	}
Exemple #27
0
void color_ideal_print_verbose(unsigned int color, IDEAL* M,
        int (*condition)(unsigned long long)) {

    if (condition == NULL) {
        ideal_print_verbose(M);
        return;
    }

    /* internals of ideal_print_verbose */
    unsigned long long i;

    if (M == NULL)
        return;

    for (i = 0; i < (M->q - 1); ++i) {
        if (M->u_s[i]) {
            if (condition(i)) {
                color_printf(color, "u_%llu ", i);
            } else {
                fprintf(stdout, "u_%llu ", i);
            }
        }
    }

    /* i = M->q - 1 */
    if (!M->u_s[i]) {
        /* only the whole group algebra contains u_(q-1) */
        fprintf(stdout, "\b\n");
    } else {
        if (condition(i)) {
            color_printf(color, "u_%llu\n", i);
        } else {
            fprintf(stdout, "u_%llu\n", i);
        }
    }
}
Exemple #28
0
int popup_do_with_condition(popup_info *pi, int flags, int(*condition)())
{
	int screen_id, choice = -1, done = 0;
	int test;

	screen_id = gr_save_screen();
	if ( popup_init(pi, flags) == -1 )
		return -1;

	while(!done) {
		int k;

		os_poll();
		
		game_set_frametime(-1);
		game_do_state_common(gameseq_get_state());	// do stuff common to all states 
		gr_restore_screen(screen_id);

		// draw one frame first
		Popup_window.draw();
		popup_force_draw_buttons(pi);
		popup_draw_msg_text(pi, flags);
		popup_draw_button_text(pi, flags);
		gr_flip();

		// test the condition function or process for the window
		if ((test = condition()) > 0) {
			done = 1;
			choice = test;
		} else {
			k = Popup_window.process();						// poll for input, handle mouse
			choice = popup_process_keys(pi, k, flags);
			if ( choice != POPUP_NOCHANGE ) {
				done=1;
			}

			if ( !done ) {
				choice = popup_check_buttons(pi);
				if ( choice != POPUP_NOCHANGE ) {
					done=1;
				}
			}
		}		
	}

	popup_close(pi,screen_id);
	return choice;
}
Exemple #29
0
Ndarray<T> & get(Ndarray<T> & a, std::function<bool(T)> condition, bool collect_original)
{
  auto& ret = array<T,T>(a);
  int cnt = 0;
  for (int i = 0; i < a.shape_prod; i++) {
    auto x = *((a.buffer) + i);
    if (condition(x)) {
      *((ret.buffer) + cnt) = x;
      cnt++;
    }
  }
  Shape new_shape(1);
  new_shape[0] = cnt;
  adjust_shape(ret);
  return ret;
}
Exemple #30
0
void PhotonMap::sampleMergePath(Path &path, Ray &prevRay, uint depth) const{
	path.push_back(prevRay);

	Ray terminateRay;
	terminateRay.origin = prevRay.origin;
	terminateRay.color = vec3f(0,0,0);
	terminateRay.direction = vec3f(0,0,0);
	terminateRay.directionSampleType = Ray::DEFINITE;
	terminateRay.insideObject = NULL;
	terminateRay.contactObject = NULL;
	terminateRay.intersectObject = NULL;

	Ray nextRay;
	if(prevRay.insideObject && !prevRay.insideObject->isVolumetric())			
		nextRay = prevRay.insideObject->scatter(prevRay);
	else if(prevRay.intersectObject){
		if(prevRay.intersectObject->isVolumetric() && prevRay.contactObject && prevRay.contactObject->isVolumetric()){
			prevRay.origin += prevRay.direction * prevRay.intersectDist;
			prevRay.intersectDist = 0;
		}
		nextRay = prevRay.intersectObject->scatter(prevRay);
	}
	else{
		path.push_back(terminateRay);	return ;
	}

	if(nextRay.direction.length() < 0.5){
		path.push_back(nextRay);		return ;
	}
	if(depth + 1 > MERGE_LEN){
		path.push_back(terminateRay);	return ;
	}
	NoSelfIntersectionCondition condition(&renderer->scene, nextRay);
	Scene::ObjSourceInformation info;
	float dist = renderer->scene.intersect(nextRay, info, &condition);
	if(dist < 0){
		path.push_back(nextRay);
		path.push_back(terminateRay);
		return ;
	}
	else{
		nextRay.intersectObject = renderer->scene.objects[info.objID];
		nextRay.intersectObjectTriangleID = info.triangleID;
		nextRay.intersectDist = dist;
	}
	sampleMergePath(path, nextRay, depth + 1);
}