当前位置: 首页>>代码示例>>C++>>正文


C++ CONTAINS函数代码示例

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


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

示例1: do_ext_or_handshake

/* Helper: Do a successful Extended ORPort authentication handshake. */
static void
do_ext_or_handshake(or_connection_t *conn)
{
  char b[256];

  tt_int_op(0, OP_EQ, connection_ext_or_start_auth(conn));
  CONTAINS("\x01\x00", 2);
  WRITE("\x01", 1);
  WRITE("But when I look ahead up the whi", 32);
  MOCK(crypto_rand, crypto_rand_return_tse_str);
  tt_int_op(0, OP_EQ, connection_ext_or_process_inbuf(conn));
  UNMOCK(crypto_rand);
  tt_int_op(TO_CONN(conn)->state, OP_EQ,
            EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_HASH);
  CONTAINS("\xec\x80\xed\x6e\x54\x6d\x3b\x36\xfd\xfc\x22\xfe\x13\x15\x41\x6b"
           "\x02\x9f\x1a\xde\x76\x10\xd9\x10\x87\x8b\x62\xee\xb7\x40\x38\x21"
           "te road There is always another ", 64);
  /* Send the right response this time. */
  WRITE("\xab\x39\x17\x32\xdd\x2e\xd9\x68\xcd\x40\xc0\x87\xd1\xb1\xf2\x5b"
        "\x33\xb3\xcd\x77\xff\x79\xbd\x80\xc2\x07\x4b\xbf\x43\x81\x19\xa2",
        32);
  tt_int_op(0, OP_EQ, connection_ext_or_process_inbuf(conn));
  CONTAINS("\x01", 1);
  tt_assert(! TO_CONN(conn)->marked_for_close);
  tt_int_op(TO_CONN(conn)->state, OP_EQ, EXT_OR_CONN_STATE_OPEN);

 done: ;
}
开发者ID:1234max,项目名称:tor,代码行数:29,代码来源:test_extorport.c

示例2: range_cmp_for_search

static int range_cmp_for_search(const void *l, const void *r) {
    range_t *left = (range_t *)l, *right = (range_t *)r;
    if (INTERSECT(left, right) ||
        CONTAINS(left, right) ||
        CONTAINS(right, left)) {
        return 0;
    }
    return left->start - right->start;
}
开发者ID:2fast4u88,项目名称:oxygen_build,代码行数:9,代码来源:rangesort.c

示例3: v3s16

bool DecoSimple::canPlaceDecoration(MMVManip *vm, v3s16 p)
{
	// Don't bother if there aren't any decorations to place
	if (c_decos.size() == 0)
		return false;

	u32 vi = vm->m_area.index(p);

	// Check if the decoration can be placed on this node
	if (!CONTAINS(c_place_on, vm->m_data[vi].getContent()))
		return false;

	// Don't continue if there are no spawnby constraints
	if (nspawnby == -1)
		return true;

	int nneighs = 0;
	v3s16 dirs[16] = {
		v3s16( 0, 0,  1),
		v3s16( 0, 0, -1),
		v3s16( 1, 0,  0),
		v3s16(-1, 0,  0),
		v3s16( 1, 0,  1),
		v3s16(-1, 0,  1),
		v3s16(-1, 0, -1),
		v3s16( 1, 0, -1),

		v3s16( 0, 1,  1),
		v3s16( 0, 1, -1),
		v3s16( 1, 1,  0),
		v3s16(-1, 1,  0),
		v3s16( 1, 1,  1),
		v3s16(-1, 1,  1),
		v3s16(-1, 1, -1),
		v3s16( 1, 1, -1)
	};

	// Check a Moore neighborhood if there are enough spawnby nodes
	for (size_t i = 0; i != ARRLEN(dirs); i++) {
		u32 index = vm->m_area.index(p + dirs[i]);
		if (!vm->m_area.contains(index))
			continue;

		if (CONTAINS(c_spawnby, vm->m_data[index].getContent()))
			nneighs++;
	}

	if (nneighs < nspawnby)
		return false;

	return true;
}
开发者ID:maksimkurb,项目名称:minetest,代码行数:52,代码来源:mg_decoration.cpp

示例4: printFaceTupleFaces

void printFaceTupleFaces(bitset tuple){
    int i, j;
    for(i=0; i<nf; i++){
        if(CONTAINS(tuple, i)){
            fprintf(stderr, "%d) ", i+1);
            for(j=0; j<nv; j++){
                if(CONTAINS(faceSets[i], j)){
                    fprintf(stderr, "%d ", j+1);
                }
            }
            fprintf(stderr, "\n");
        }
    }
}
开发者ID:nvcleemp,项目名称:eopd,代码行数:14,代码来源:find_eopd_4_tuple.c

示例5: addWidget

void Dashboard::addWidget(DashboardWidget *widget)
{
    if (CONTAINS(widgets, widget))
        return;
    
    widgets.push_back(widget);
}
开发者ID:goc9000,项目名称:megas2,代码行数:7,代码来源:dashboard.cpp

示例6: pr

void OreScatter::generate(ManualMapVoxelManipulator *vm, int seed,
						  u32 blockseed, v3s16 nmin, v3s16 nmax) {
	PseudoRandom pr(blockseed);
	MapNode n_ore(c_ore, 0, ore_param2);

	int volume = (nmax.X - nmin.X + 1) *
				 (nmax.Y - nmin.Y + 1) *
				 (nmax.Z - nmin.Z + 1);
	int csize     = clust_size;
	int orechance = (csize * csize * csize) / clust_num_ores;
	int nclusters = volume / clust_scarcity;

	for (int i = 0; i != nclusters; i++) {
		int x0 = pr.range(nmin.X, nmax.X - csize + 1);
		int y0 = pr.range(nmin.Y, nmax.Y - csize + 1);
		int z0 = pr.range(nmin.Z, nmax.Z - csize + 1);

		if (np && (NoisePerlin3D(np, x0, y0, z0, seed) < nthresh))
			continue;

		for (int z1 = 0; z1 != csize; z1++)
		for (int y1 = 0; y1 != csize; y1++)
		for (int x1 = 0; x1 != csize; x1++) {
			if (pr.range(1, orechance) != 1)
				continue;

			u32 i = vm->m_area.index(x0 + x1, y0 + y1, z0 + z1);
			if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
				continue;

			vm->m_data[i] = n_ore;
		}
	}
}
开发者ID:Shammmmmm,项目名称:minetest,代码行数:34,代码来源:mapgen.cpp

示例7: removeDevice

void VirtualNetwork::removeDevice(NetworkDevice *device)
{
    if (CONTAINS(devices, device)) {
        this->devices.erase(FIND(devices, device));
        device->disconnectFromNetwork();
    }
}
开发者ID:goc9000,项目名称:megas2,代码行数:7,代码来源:virtual_net.cpp

示例8: generate

size_t DecoSchematic::generate(MMVManip *vm, PseudoRandom *pr, v3s16 p)
{
	// Schematic could have been unloaded but not the decoration
	// In this case generate() does nothing (but doesn't *fail*)
	if (schematic == NULL)
		return 0;

	u32 vi = vm->m_area.index(p);
	content_t c = vm->m_data[vi].getContent();
	if (!CONTAINS(c_place_on, c))
		return 0;

	if (flags & DECO_PLACE_CENTER_X)
		p.X -= (schematic->size.X - 1) / 2;
	if (flags & DECO_PLACE_CENTER_Y)
		p.Y -= (schematic->size.Y - 1) / 2;
	if (flags & DECO_PLACE_CENTER_Z)
		p.Z -= (schematic->size.Z - 1) / 2;

	Rotation rot = (rotation == ROTATE_RAND) ?
		(Rotation)pr->range(ROTATE_0, ROTATE_270) : rotation;

	bool force_placement = (flags & DECO_FORCE_PLACEMENT);

	schematic->blitToVManip(p, vm, rot, force_placement);

	return 1;
}
开发者ID:maksimkurb,项目名称:minetest,代码行数:28,代码来源:mg_decoration.cpp

示例9: findEOPD

boolean findEOPD(bitset tuple){
    int i, j;
    //first we check the stored OPD's
    for(i = 0; i < eopdCount; i++){
        bitset intersectionOpd = INTERSECTION(tuple, opdFaces[i]);
        bitset intersectionExtensions = INTERSECTION(tuple, extensionFaces[i]);
        if((IS_NOT_EMPTY(intersectionOpd) && IS_NOT_EMPTY(intersectionExtensions)) ||
                (HAS_MORE_THAN_ONE_ELEMENT(intersectionOpd))){
            numberOfTuplesCoveredByStoredOpd++;
            return TRUE;
        }
    }
    
    //then we try to find a new eOPD
    for(i = 0; i < nf; i++){
        if(CONTAINS(tuple, i)){
            //try to find a eOPD with face i as extension
            bitset remainingFaces = MINUS(tuple, i);
            //we use each edge once as a possible shared edge 
            EDGE *sharedEdge = facestart[i];
            for(j = 0; j < 3; j++){
                //construct initial eopd
                int neighbouringFace = sharedEdge->inverse->rightface;
                bitset currentEopdVertices = faceSets[neighbouringFace];
                bitset currentEopdFaces = UNION(SINGLETON(i), SINGLETON(neighbouringFace));
                if(findEOPD_impl(currentEopdVertices, currentEopdFaces, i, remainingFaces, sharedEdge->inverse)){
                    return TRUE;
                }
                sharedEdge = sharedEdge->next->inverse;
            }
        }
    }
    return FALSE;
}
开发者ID:nvcleemp,项目名称:eopd,代码行数:34,代码来源:eopd.c

示例10: printVector

void printVector(FILE *f, bitset vector){
    int i;
    
    for(i = 0; i < n; i++){
        fprintf(f, CONTAINS(vector, i) ? "1" : "0");
    }
    fprintf(f, "\n");
}
开发者ID:nvcleemp,项目名称:thrackles,代码行数:8,代码来源:crossing_parity_vectors.c

示例11: addDevice

void VirtualNetwork::addDevice(NetworkDevice *device)
{
    if (CONTAINS(devices, device))
        return;
    
    devices.push_back(device);
    device->connectToNetwork(this);
}
开发者ID:goc9000,项目名称:megas2,代码行数:8,代码来源:virtual_net.cpp

示例12: get

bool NodeDefManager::nodeboxConnects(MapNode from, MapNode to,
	u8 connect_face) const
{
	const ContentFeatures &f1 = get(from);

	if ((f1.drawtype != NDT_NODEBOX) || (f1.node_box.type != NODEBOX_CONNECTED))
		return false;

	// lookup target in connected set
	if (!CONTAINS(f1.connects_to_ids, to.param0))
		return false;

	const ContentFeatures &f2 = get(to);

	if ((f2.drawtype == NDT_NODEBOX) && (f2.node_box.type == NODEBOX_CONNECTED))
		// ignores actually looking if back connection exists
		return CONTAINS(f2.connects_to_ids, from.param0);

	// does to node declare usable faces?
	if (f2.connect_sides > 0) {
		if ((f2.param_type_2 == CPT2_FACEDIR ||
				f2.param_type_2 == CPT2_COLORED_FACEDIR)
				&& (connect_face >= 4)) {
			static const u8 rot[33 * 4] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 4, 32, 16, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, // 4 - back
				8, 4, 32, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, // 8 - right
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 8, 4, 32, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, // 16 - front
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 32, 16, 8, 4 // 32 - left
				};
			return (f2.connect_sides
				& rot[(connect_face * 4) + (to.param2 & 0x1F)]);
		}
		return (f2.connect_sides & connect_face);
	}
	// the target is just a regular node, so connect no matter back connection
	return true;
}
开发者ID:Caellian,项目名称:minetest,代码行数:43,代码来源:nodedef.cpp

示例13: registerConsumer

bool ModChannel::registerConsumer(session_t peer_id)
{

	// ignore if peer_id already joined
	if (CONTAINS(m_client_consumers, peer_id))
		return false;

	m_client_consumers.push_back(peer_id);
	return true;
}
开发者ID:Caellian,项目名称:minetest,代码行数:10,代码来源:modchannels.cpp

示例14: printVertexTuple

void printVertexTuple(bitset tuple){
    int i;
    fprintf(stderr, "Vertex tuple: ");
    for(i=0; i<nv; i++){
        if(CONTAINS(tuple, i)){
            fprintf(stderr, "%d ", i+1);
        }
    }
    fprintf(stderr, "\n");
}
开发者ID:nvcleemp,项目名称:eopd,代码行数:10,代码来源:find_eopd_4_tuple.c

示例15: printFaceTuple

void printFaceTuple(bitset tuple){
    int i;
    fprintf(stderr, "Face tuple: ");
    for(i=0; i<nf; i++){
        if(CONTAINS(tuple, i)){
            fprintf(stderr, "%d ", i+1);
        }
    }
    fprintf(stderr, "\n");
}
开发者ID:nvcleemp,项目名称:eopd,代码行数:10,代码来源:find_eopd_4_tuple.c


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