• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ COMPARE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中COMPARE函数的典型用法代码示例。如果您正苦于以下问题:C++ COMPARE函数的具体用法?C++ COMPARE怎么用?C++ COMPARE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了COMPARE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: check_tree

int
check_tree(rb_tree *tree, rb_node *node) {
    rb_node *nil = tree->nil;
    if (node == nil) {
        assert(!node->red);
        return 1;
    }
    if (node->left != nil) {
        assert(COMPARE(tree, node, node->left) >= 0);
        assert(node->left->parent == node);
    }
    if (node->right != nil) {
        assert(COMPARE(tree, node, node->right) <= 0);
        assert(node->right->parent == node);
    }
    if (node->red) {
        assert(!node->left->red && !node->right->red);
    }
    int hb_left = check_tree(tree, node->left);
    int hb_right = check_tree(tree, node->right);
    assert(hb_left == hb_right);
    int hb = hb_left;
    if (!node->red) {
        hb ++;
    }
    return hb;
}
开发者ID:121786404,项目名称:liunix,代码行数:27,代码来源:rb_tree.c


示例2: compare_IDEs

static int
compare_IDEs(const void *ap, const void *bp)
{
    const XPTInterfaceDirectoryEntry *a = ap, *b = bp;
    const nsID *aid = &a->iid, *bid = &b->iid;
    const char *ans, *bns;

    int i;
#define COMPARE(field) if (aid->field > bid->field) return 1; \
                       if (bid->field > aid->field) return -1;
    COMPARE(m0);
    COMPARE(m1);
    COMPARE(m2);
    for (i = 0; i < 8; i++) {
        COMPARE(m3[i]);
    }

    /* defend against NULL name_space by using empty string. */
    ans = a->name_space ? a->name_space : "";
    bns = b->name_space ? b->name_space : "";

    if (a->name_space && b->name_space) {
        if ((i = strcmp(a->name_space, b->name_space)))
            return i;
    } else {
        if (a->name_space || b->name_space) {
            if (a->name_space)
                return -1;
            return 1;
        }
    }
    /* these had better not be NULL... */
    return strcmp(a->name, b->name);
#undef COMPARE
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:35,代码来源:xpidl_typelib.c


示例3: radix_get

LEAFTYPE
radix_get(struct ROOTSTRUCT * tree, LEAFTYPE leaf, EXTRA_ARG aux) {
    LEAFTYPE result;
    struct _internal_node * node;
    uint32_t dir;

    if (tree->leafcount == 0) return NO_LEAF;
    if (tree->leafcount == 1) {
        result = tree->root.leaf;
        if (COMPARE(result, leaf) == -1) return result;
        else return NO_LEAF;
    } /* root points to a node */

    node = tree->root.node;
    while (1) {
        dir = DECIDE(leaf, node->critbit, aux);
        if (IS_LEAF(node, dir)) {
            result = node->child[dir].leaf;
            break;
        } else {
            node = node->child[dir].node;
        }
    }

    if (COMPARE(result, leaf) == -1) return result;
    else return NO_LEAF;
}
开发者ID:donwen9011,项目名称:tiksock,代码行数:27,代码来源:radix.c


示例4: html_Tag_compare

static PyObject *
html_Tag_compare(html_Tag *a, html_Tag *b, int op) {
    if (!PyObject_TypeCheck(a, &html_TagType) || !PyObject_TypeCheck(b, &html_TagType)) {
        switch (op) {
            case Py_EQ:
                Py_RETURN_FALSE;
            case Py_NE:
                Py_RETURN_TRUE;
            default:
                break;
        }
    } else {
        switch (op) {
            case Py_EQ:
                if (COMPARE(name, Py_EQ) && COMPARE(lang, Py_EQ)) Py_RETURN_TRUE;
                Py_RETURN_FALSE;
            case Py_NE:
                if (COMPARE(name, Py_NE) || COMPARE(lang, Py_NE)) Py_RETURN_TRUE;
                Py_RETURN_FALSE;
            default:
                break;
        }
    }
    PyErr_SetString(PyExc_TypeError, "Only equals comparison is supported for Tag objects");
    return NULL;
}
开发者ID:AEliu,项目名称:calibre,代码行数:26,代码来源:html.c


示例5: testprim1_compare

static int
testprim1_compare(PrimRequired* input, PrimRequired* output)
{
    COMPARE(input,output,int32);
    COMPARE(input,output,int64);
    COMPARE(input,output,uint32);
    COMPARE(input,output,uint64);
    COMPARE(input,output,sint32);
    COMPARE(input,output,sint64);
    COMPARE(input,output,fixed32);
    COMPARE(input,output,fixed64);
    COMPARE(input,output,sfixed32);
    COMPARE(input,output,sfixed64);
    COMPARE(input,output,double);
    COMPARE(input,output,float);
    if(input->f_int64 != output->f_int64) return 0;
    if(input->f_uint32 != output->f_uint32) return 0;
    if(input->f_uint64 != output->f_uint64) return 0;
    if(input->f_sint32 != output->f_sint32) return 0;
    if(input->f_sint64 != output->f_sint64) return 0;
    if(input->f_fixed32 != output->f_fixed32) return 0;
    if(input->f_fixed64 != output->f_fixed64) return 0;
    if(input->f_sfixed32 != output->f_sfixed32) return 0;
    if(input->f_sfixed64 != output->f_sfixed64) return 0;
    if(input->f_double != output->f_double) return 0;
    if(input->f_float != output->f_float) return 0;
    return 1;
}
开发者ID:DennisHeimbigner,项目名称:ast,代码行数:28,代码来源:testprim1.c


示例6: readData

	void readData()
	{
		scanf("%d%d", &toyNum, &compareTimes);
		vtxNum = toyNum + compareTimes + 2;
		source = vtxNum - 2, sink = vtxNum - 1;

		for(int i = 0; i < toyNum; i ++)
		{
			scanf("%d%d", &initLowerBound[i], &initUpperBound[i]);
			initLowerBound[i] = max(initLowerBound[i], 0);
			initUpperBound[i] = min(initUpperBound[i], 20000);
		}
		for(int i = 0, l, r, d; i < compareTimes; i ++)
		{
			scanf("%d%d%d", &l, &r, &d);
			if(d > 0)
				addEdge(COMPARE(i), sink, d, d);
			else if(d < 0)
				addEdge(source, COMPARE(i), -d, -d);
			int toyIdx;
			while(l --)
			{
				scanf("%d", &toyIdx);
				toyIdx --;
				addEdge(TOY(toyIdx), COMPARE(i), 0, INFINITY);
			}
			while(r --)
			{
				scanf("%d", &toyIdx);
				toyIdx --;
				addEdge(COMPARE(i), TOY(toyIdx), 0, INFINITY);
			}
		}
	}
开发者ID:alxsoares,项目名称:OI,代码行数:34,代码来源:p1158.cpp


示例7: compare_ts

/* Returns +ve number if ts1 > ts2, -ve if ts1 < ts2, 0 if ts1 == ts2. */
static int compare_ts(struct timespec *ts1, struct timespec *ts2)
{
    if (ts1->tv_sec == ts2->tv_sec)
        return COMPARE(ts1->tv_nsec, ts2->tv_nsec);
    else
        return COMPARE(ts1->tv_sec, ts2->tv_sec);
}
开发者ID:Araneidae,项目名称:fa-archiver,代码行数:8,代码来源:capture.c


示例8: minHeapify

void minHeapify(int* A, int i){
    /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
    /*  Inputs:                                                     */
    /*          A   :   int array    array of indices               */
    /*          i   :   int          index or current vertex        */
    /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
    
    int leftChild = left(i);
    int rightChild = right(i);
    int smallest;
    
    if(leftChild <= heapSize && COMPARE(A[leftChild],A[i]) == 2){
        smallest = leftChild;
    }
    else{
        smallest = i;
    }
    
    if(rightChild <= heapSize && COMPARE(A[rightChild], A[smallest]) == 2 ){
        smallest = rightChild;
    }
    
    if(smallest != i){
        // we are not switching hidden, we are switching indices associated with it
        int temp = A[i];
        A[i] = A[smallest];
        A[smallest] = temp;
        
        minHeapify(A, smallest);
    }
}
开发者ID:annecab,项目名称:cs165Project1,代码行数:31,代码来源:doalg.c


示例9: LoadScene

void LoadScene(TiXmlElement *element)
{
    for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
        
        if ( COMPARE( child->Value(), "background" ) ) {
            Color c(1,1,1);
            ReadColor( child, c );
            background.SetColor(c);
            printf("Background %f %f %f\n",c.r,c.g,c.b);
            background.SetTexture( ReadTexture(child) );
        } else if ( COMPARE( child->Value(), "environment" ) ) {
            Color c(1,1,1);
            ReadColor( child, c );
            environment.SetColor(c);
            printf("Environment %f %f %f\n",c.r,c.g,c.b);
            environment.SetTexture( ReadTexture(child) );
        } else if ( COMPARE( child->Value(), "object" ) ) {
            LoadNode( &rootNode, child );
        } else if ( COMPARE( child->Value(), "material" ) ) {
            LoadMaterial( child );
        } else if ( COMPARE( child->Value(), "light" ) ) {
            LoadLight( child );
        }
    }
}
开发者ID:varunk08,项目名称:raytracing,代码行数:25,代码来源:xmlload.cpp


示例10: LoadTransform

void LoadTransform( Transformation *trans, TiXmlElement *element, int level )
{
    for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
        if ( COMPARE( child->Value(), "scale" ) ) {
            Point3 s(1,1,1);
            ReadVector( child, s );
            trans->Scale(s.x,s.y,s.z);
            PrintIndent(level);
            printf("   scale %f %f %f\n",s.x,s.y,s.z);
        } else if ( COMPARE( child->Value(), "rotate" ) ) {
            Point3 s(0,0,0);
            ReadVector( child, s );
            s.Normalize();
            float a;
            ReadFloat(child,a,"angle");
            trans->Rotate(s,a);
            PrintIndent(level);
            printf("   rotate %f degrees around %f %f %f\n", a, s.x, s.y, s.z);
        } else if ( COMPARE( child->Value(), "translate" ) ) {
            Point3 t(0,0,0);
            ReadVector(child,t);
            trans->Translate(t);
            PrintIndent(level);
            printf("   translate %f %f %f\n",t.x,t.y,t.z);
        }
    }
}
开发者ID:varunk08,项目名称:raytracing,代码行数:27,代码来源:xmlload.cpp


示例11: printTitle

QString MultiModelPrinter::printMixers()
{
  QString str = printTitle(tr("Mixers"));
  MultiColumns columns(models.size());
  columns.append("<table cellspacing='0' cellpadding='1' width='100%' border='0' style='border-collapse:collapse'>");
  for (int i=0; i<firmware->getCapability(Outputs); i++) {
    int count = 0;
    for (int k=0; k<models.size(); k++) {
      count = std::max(count, models[k]->mixes(i).size());
    }
    if (count > 0) {
      columns.append("<tr><td width='20%'><b>");
      COMPARE(modelPrinter->printMixerName(i+1));
      columns.append("</b></td><td>");
      for (int j=0; j<count; j++) {
        if (j > 0)
          columns.append("<br/>");
        COMPARE((j < model->mixes(i).size()) ? modelPrinter->printMixerLine(*model->mixes(i)[j], (j>0)) : "&nbsp;");
      }
      columns.append("</td></tr>");
    }
  }
  str.append(columns.print());
  return str;
}
开发者ID:BenZoFly,项目名称:opentx,代码行数:25,代码来源:multimodelprinter.cpp


示例12: simple_test

void simple_test()
{
    std::string expression = "4+3*(5-1)-8/2";
    COMPARE(evaluate(std::begin(expression), std::end(expression)), 12);

    expression = "((2-3)*3/3+5)/4";
    COMPARE(evaluate(std::begin(expression), std::end(expression)), 1);
}
开发者ID:kurdybacha,项目名称:misc,代码行数:8,代码来源:calculator.cpp


示例13: sort_by_score_desc

static int sort_by_score_desc(const void *v1, const void *v2)
{
	const struct pair *p1 = v1;
	const struct pair *p2 = v2;
	if (p2->score == p1->score) {
		return COMPARE(p1->index, p2->index);
	}
	return COMPARE(p2->score, p1->score);
}
开发者ID:rfalke,项目名称:decreasefileredundency,代码行数:9,代码来源:calc_histogram_distance.c


示例14: main

int main()
{
	printf("Testing subscriber database code.\n");
	osmo_init_logging(&log_info);

	if (db_init("hlr.sqlite3")) {
		printf("DB: Failed to init database. Please check the option settings.\n");
		return 1;
	}	 
	printf("DB: Database initialized.\n");

	if (db_prepare()) {
		printf("DB: Failed to prepare database.\n");
		return 1;
	}
	printf("DB: Database prepared.\n");

	struct gsm_subscriber *alice = NULL;
	struct gsm_subscriber *alice_db;

	char *alice_imsi = "3243245432345";
	alice = db_create_subscriber(NULL, alice_imsi);
	db_sync_subscriber(alice);
	alice_db = db_get_subscriber(NULL, GSM_SUBSCRIBER_IMSI, alice->imsi);
	COMPARE(alice, alice_db);
	SUBSCR_PUT(alice_db);
	SUBSCR_PUT(alice);

	alice_imsi = "3693245423445";
	alice = db_create_subscriber(NULL, alice_imsi);
	db_subscriber_assoc_imei(alice, "1234567890");
	db_subscriber_alloc_tmsi(alice);
	alice->lac=42;
	db_sync_subscriber(alice);
	alice_db = db_get_subscriber(NULL, GSM_SUBSCRIBER_IMSI, alice_imsi);
	COMPARE(alice, alice_db);
	SUBSCR_PUT(alice);
	SUBSCR_PUT(alice_db);

	alice_imsi = "9993245423445";
	alice = db_create_subscriber(NULL, alice_imsi);
	db_subscriber_alloc_tmsi(alice);
	alice->lac=42;
	db_sync_subscriber(alice);
	db_subscriber_assoc_imei(alice, "1234567890");
	db_subscriber_assoc_imei(alice, "6543560920");
	alice_db = db_get_subscriber(NULL, GSM_SUBSCRIBER_IMSI, alice_imsi);
	COMPARE(alice, alice_db);
	SUBSCR_PUT(alice);
	SUBSCR_PUT(alice_db);

	db_fini();

	printf("Done\n");
	return 0;
}
开发者ID:YBouzid,项目名称:openbsc,代码行数:56,代码来源:db_test.c


示例15: multi_hash

//²úÉú hash±í
int multi_hash(hash_paramiter *para)
{
int conflict,i,hashnum;
int *lp;
multi_hash_node *hash,*top,*hp,stack[para->key_count];

	if(!para) return -1;
	para->index=hash=(multi_hash_node *)malloc(para->key_count * sizeof(multi_hash_node));
	if(!hash) {
		return MEMERR;
	}

	top=stack;
	for(i=0;i<para->key_count;i++) {
		hash[i].rowno=-1;
		hash[i].link=-1;
		hash[i].count=0;
	}
//ShowLog(5,"multi_hash:data_count=%d,key_count=%d",para->data_count,para->key_count);
	for(i=0;i<para->data_count;i++) {
	    hashnum=para->do_hash(GETDATA(i),para->key_count);
	    hp=&hash[hashnum];
	    if(hp->rowno==-1) {	//ûÓÐÉ¢ÁгåÍ» 
		hp->rowno=i;
		hp->count=1;
	    } else if(!COMPARE(i,hp->rowno)) {	//¼ì²éÖØÂ룬¹¹½¨ÖØÂëÁ´
		hp->count++;
		continue;
	    } else {				//ÓÐÉ¢ÁгåÍ»£¬´æ´¢³åÍ»Á´
		if(top>stack&&!COMPARE(i,top[-1].rowno)) {
			top[-1].count++;
			continue;
		}
		top->rowno=i;
		top->link=hashnum;
		top->count=1;
		top++;
	    }
	}
	conflict=top-stack;
	if(top > stack) { //ÓÐÉ¢ÁгåÍ»£¬¹¹½¨³åÍ»Á´ 
		hp=hash;
		for(i=0;top>stack&&i<para->key_count;i++,hp++) {
			if(hp->rowno > -1) continue;
			top--;
//ÕÒµ½Ë÷Òý±íÀïµÄ¿ÕÏî 
			hp->rowno=top->rowno;
			hp->count=top->count;
			hp->link=-1;
			for(lp=&top->link;*lp != -1;lp=&hash[*lp].link)
				;
			*lp=i;
		}
	}
	return conflict;
}
开发者ID:hx71105417,项目名称:sdbc_linux,代码行数:57,代码来源:multi_hash.c


示例16: GetProfileOrdering

  bool ProfileLimits::operator> (const ProfileLimits& other) const
  {
    int p1 = GetProfileOrdering (profile);
    int p2 = GetProfileOrdering (other.profile);
    if (p1 > p2) return true;
    if (p1 < p2) return false;
  
    if (vendor > other.vendor) return true;
    if (vendor < other.vendor) return false;
  
#define COMPARE(Limit) \
    if (Limit > other.Limit) return true; \
    if (Limit < other.Limit) return false;
    COMPARE (extensions); // @@@ Right?
    COMPARE (MaxInstructions);
    COMPARE (NumInstructionSlots);
    COMPARE (NumMathInstructionSlots);
    COMPARE (NumTexInstructionSlots);
    COMPARE (NumTemps);
    COMPARE (MaxLocalParams);
    COMPARE (MaxTexIndirections);
    COMPARE (MaxAddressRegs);
#undef COMPARE
    return false;
  }
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:25,代码来源:profile_limits.cpp


示例17: insert_heap

    void
insert_heap(
        const sort_t* s,
        int index)
{
    int i;

    for (i = index; i < s->count; )
    {
        int index1 = i * 2 + 1;
        int index2 = index1 + 1;

        if (index2 < s->count)
        {
            char* item0 = s->head + i * s->size;
            char* item1 = s->head + index1 * s->size;
            char* item2 = item1 + s->size;

            if (COMPARE(s, item1, item2) > 0)
            {
                int index = index1;
                char* item = item1;
                index1 = index2;
                index2 = index;
                item1 = item2;
                item2 = item;
            }

            if (COMPARE(s, item0, item1) > 0)
            {
                SWAP(item0, item1, s->size);
                i = index1;
                continue;
            }
            else if (COMPARE(s, item0, item2) > 0)
            {
                SWAP(item0, item2, s->size);
                i = index2;
                continue;
            }
        }
        else if (index1 < s->count)
        {
            char* item0 = s->head + i * s->size;
            char* item1 = s->head + index1 * s->size;
            if (COMPARE(s, item0, item1) > 0)
            {
                SWAP(item0, item1, s->size);
            }
        }

        break;
    }
}
开发者ID:koron,项目名称:sort-argorithm,代码行数:54,代码来源:heap_sort.c


示例18: COMPARE

bool BackgroundDef::operator<( const BackgroundDef &other ) const
{
#define COMPARE(x) if( x < other.x ) return true; else if( x > other.x ) return false;
	COMPARE( m_sEffect );
	COMPARE( m_sFile1 );
	COMPARE( m_sFile2 );
	COMPARE( m_sColor1 );
	COMPARE( m_sColor2 );
#undef COMPARE
	return false;
}
开发者ID:goofwear,项目名称:stepmania,代码行数:11,代码来源:BackgroundUtil.cpp


示例19: rdistribute

/*
 * Mirror image to ldistribute: stably distribute a buffer of
 * "bufsize" elements from the _end_ of the sequence of "nmemb"
 * elements starting at "start" throughout the rest of the
 * sequence, assuming elements in the buffer to come _after_
 * things in the main sequence.
 *
 * Hideous clone-and-hack of ldistribute. I'd much rather have a
 * useful way of combining the two routines into one piece of
 * source code.
 */
static void rdistribute(void *base, size_t size, cmpfn compare CTXPARAM,
 			size_t start, size_t nmemb, size_t bufsize)
{
    size_t bufbot = start + nmemb - bufsize;

    while (bufsize > 0) {
	size_t buftop = bufbot + bufsize;
	/*
	 * Binary-search in the main array (or rather, that part
	 * of it from buftop upwards) to find where the element at
	 * buftop-1 should be placed. In the event of a tie,
	 * stability is preserved by treating bufbot as coming
	 * after any other indistinguishable element.
	 */
	size_t bot = start-1, top = bufbot, mid;

	while (top - bot > 1) {
	    mid = (top + bot) / 2;
	    if (COMPARE(buftop-1, mid) < 0)
		top = mid;
	    else
		bot = mid;
	}

	/*
	 * Now we have a piece of array looking like this:
	 *
	 *  top               bufbot     buftop
	 *   +------------------+--------+-+
	 *   |         B        |    A   |X|
	 *   +------------------+--------+-+
	 *
	 * and we need it to look like this:
	 *   +--------+-+------------------+
	 *   |    A   |X|         B        |
	 *   +--------+-+------------------+
	 *
	 * This is therefore a trivial block exchange: we move
	 * the whole buffer to after B, and then just stop
	 * considering element X to be part of the buffer.
	 */
	block_exchange(base, size, top, bufbot - top, bufsize);
	bufbot = top;
	buftop = bufbot + bufsize;
	/*
	 * As in ldistribute, we must skip over identical elements
	 * here, to preserve linear time complexity.
	 */
	do {
	    bufsize--;
	} while (bufsize > 0 && COMPARE(bufbot + bufsize-1, buftop-1) == 0);
    }
}
开发者ID:rdebath,项目名称:sgt,代码行数:64,代码来源:amergesort.c


示例20: SELECT2

int SELECT2(int arr[], int n, int k)
{
	if(n<25)
	{
		return insertion_sort(arr, n, k);
	}

	int V = arr[random_int(0,n)];

	int *L = malloc(n * sizeof(*L));
	int *E = malloc(n * sizeof(*E));
	int *G = malloc(n * sizeof(*G));

	int i=0, l=0, e=0, g=0;

	while(i<n)
	{
		if(COMPARE(arr[i],V) == 2) //(arr[i]<V)
		{
			L[l] = arr[i];
			l++;
		}
		else if(COMPARE(arr[i], V) == 1) //(arr[i]==V)
		{
			E[e] = arr[i];
			e++;
		}
		else
		{
			G[g] = arr[i];
			g++;
		}
		i++;
	}

	if(k<=l)
	{
		SELECT2(L, l, k);
	}
	else if(k<=l+e)
	{
		return(V);
	}
	else
	{
		SELECT2(G, g, k - l - e);
	}
	
	


}
开发者ID:D0wney,项目名称:Algorithms,代码行数:52,代码来源:program2.c



注:本文中的COMPARE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ COMPILE_ASSERT函数代码示例发布时间:2022-05-30
下一篇:
C++ COMP函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap