您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ COMPARE函数代码示例

51自学网 2021-06-01 20:03:35
  C++
这篇教程C++ COMPARE函数代码示例写得很实用,希望能帮到您。

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

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

示例1: check_tree

intcheck_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,


示例2: compare_IDEs

static intcompare_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,


示例3: radix_get

LEAFTYPEradix_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,


示例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,


示例5: testprim1_compare

static inttestprim1_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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。