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


C++ BitArray::clear方法代码示例

本文整理汇总了C++中BitArray::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ BitArray::clear方法的具体用法?C++ BitArray::clear怎么用?C++ BitArray::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitArray的用法示例。


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

示例1: setUpperCaseBit

void FullContainerKey::setUpperCaseBit(const FullContainerKeyComponents &components,
									   BitArray &upperCaseBit) const {
	upperCaseBit.clear();

	const char8_t *strList[3] = { components.baseName_, components.affinityString_, components.systemPart_ };
	uint32_t lengthList[3] = { components.baseNameSize_, components.affinityStringSize_, components.systemPartSize_ };

	for (size_t i = 0; i < 3; i++) {
		for (size_t j = 0; j < lengthList[i]; j++) {
			upperCaseBit.append(isupper(strList[i][j]) != 0);
		}
	}
}
开发者ID:AnggaSuherman,项目名称:griddb_nosql,代码行数:13,代码来源:container_key.cpp

示例2: writefile

void Tree::writefile(char *pathIn){
    ifstream file;
    ofstream write;
    string aux;
    string aux2;
    string temporaria;
    int sobra = 0;
    int sizefile = 0;
    BitArray *buffer = new BitArray();

    aux.clear();
    temporaria.clear();
    codificar(root, aux);
    aux.clear();

    file.open(pathIn , ios::in | ios::binary | ios::ate);

    if(file.is_open()){

        int size = file.tellg();
        file.seekg(0, ios::beg);
        int i;
        int iw =1;

        for(i=0; i< size; i++){
            unsigned char c = file.get();
            int j = c;
            aux += codeNodes[j];
            if(aux.length() >= 1024*8){
                sobra = aux.length() - 1024*8;
                temporaria = aux.substr(1024*8, sobra);
                for(int k = 0;k < (aux.length()/8); k++){
                    int n = k*8;
                    aux2 = aux.substr(n, 8);
                    codenode_to_bitarray(aux2, buffer);

                }
                iw++;
                write.open("temp.huff", ios::out | ios::binary | ios::app);
                if(write.is_open()){
                    for(int z = 0;z < aux.length()/8;z++){
                        write << buffer->getArray()[z];
                        sizefile++;
                    }
                }

                write.close();
                aux.clear();
                aux = temporaria;
                buffer->clear();
            }
        }
        int y = (aux.length()/8);
        sobra = aux.length() - (y*8);
        aux2 = aux.substr(y*8,sobra);
        string teste = aux2;


        for(int k = 0;k < (aux.length()/8); k++){
            int n = k*8;
            aux2 = aux.substr(n, 8);
            codenode_to_bitarray(aux2, buffer);

        }

        int u = 8 - sobra;
        sizeTrash = u;
        aux2 = teste;

        for(int i = 0;i < u;i++){
            aux2 += '0';
        }

        codenode_to_bitarray(aux2, buffer);

        sizeLast = (buffer->getCurrent() / 8);
        sizeLast--;

        write.open("temp.huff", ios::out | ios::binary | ios::app);

        if(write.is_open()){
            for(int z=0; z <= sizeLast;z++){
                write << buffer->getArray()[z];

                sizefile++;
            }
        }
        write.close();

        sizeTrash = buffer->trashLenght();


        buffer->clear();

    }
    else cout << "TRASH!in WriteFile" << endl;
    file.close();

}
开发者ID:matheus013,项目名称:Huffman-in-Cplusplus,代码行数:99,代码来源:Tree.cpp

示例3: deserialize

void FullContainerKey::deserialize(util::StackAllocator &alloc,
								   FullContainerKeyComponents &components,
								   BitArray &upperCaseBit,
								   bool unNormalized) const {
	try {
		if (isEmpty()) {
			GS_THROW_USER_ERROR(GS_ERROR_DS_DS_CONTAINER_NAME_INVALID,
				"container/table name is empty");
		}

		components.clear();
		upperCaseBit.clear();

		ContainerKeyInStream in(util::ArrayInStream(body_, size_));

		const char8_t *normalizedStr[3] = { NULL, NULL, NULL };

		uint8_t flag;
		in >> flag;

		if (flag & DBID_EXISTS) {
			in >> components.dbId_;
		}
		else {
			components.dbId_ = GS_PUBLIC_DB_ID;
		}

		components.baseNameSize_ = decodeVarInt(in);
		normalizedStr[0] = reinterpret_cast<const char8_t*>(body_ + in.base().position());
		in.base().position(in.base().position() + components.baseNameSize_);

		if (flag & LARGE_CONTAINERID_EXISTS) {
			components.largeContainerId_ = decodeVarLong(in);
		}

		if (flag & NODE_AFFINITY_NUM) {
			components.affinityNumber_ = decodeVarLong(in);
		}
		else if (flag & NODE_AFFINITY_STR) {
			components.affinityStringSize_ = decodeVarInt(in);
			normalizedStr[1] = reinterpret_cast<const char8_t*>(body_ + in.base().position());
			in.base().position(in.base().position() + components.affinityStringSize_);
		}

		if (flag & SYSTEM_PART_ID_NUM) {
			components.systemPartId_ = decodeVarLong(in);
		}
		else if (flag & SYSTEM_PART_ID_STR) {
			components.systemPartSize_ = decodeVarInt(in);
			normalizedStr[2] = reinterpret_cast<const char8_t*>(body_ + in.base().position());
			in.base().position(in.base().position() + components.systemPartSize_);
		}

		const uint64_t strLength = components.baseNameSize_
			+ components.affinityStringSize_
			+ components.systemPartSize_;

		if (in.base().remaining() != strLengthToBitLength(strLength)) {
			GS_THROW_USER_ERROR(GS_ERROR_DS_DS_CONTAINER_NAME_INVALID,
				"size of container/table name is invalid");
		}
		else {
			upperCaseBit.reserve(strLength);
			upperCaseBit.putAll(body_ + in.base().position(), strLength);
			in.base().position(in.base().position() + in.base().remaining());
		}

		if (in.base().position() != size_) {
			GS_THROW_USER_ERROR(GS_ERROR_DS_DS_CONTAINER_NAME_INVALID,
				"size of container/table name is invalid");
		}


		if (unNormalized) {
			util::XArray<char8_t> buf(alloc);
			buf.resize(static_cast<size_t>(strLength), '\0');
			uint64_t startPos = 0;

			createOriginalString(normalizedStr[0], components.baseNameSize_,
				buf.data()+startPos, upperCaseBit, startPos);
			components.baseName_ = buf.data()+startPos;
			startPos += components.baseNameSize_;

			if (components.affinityStringSize_ > 0) {
				createOriginalString(normalizedStr[1], components.affinityStringSize_,
					buf.data()+startPos, upperCaseBit, startPos);
				components.affinityString_ = buf.data()+startPos;
				startPos += components.affinityStringSize_;
			}

			if (components.systemPartSize_ > 0) {
				createOriginalString(normalizedStr[2], components.systemPartSize_,
					buf.data()+startPos, upperCaseBit, startPos);
				components.systemPart_ = buf.data()+startPos;
				startPos += components.systemPartSize_;
			}
		}
		else {
			components.baseName_ = normalizedStr[0];
			if (components.affinityStringSize_ > 0) {
//.........这里部分代码省略.........
开发者ID:AnggaSuherman,项目名称:griddb_nosql,代码行数:101,代码来源:container_key.cpp


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