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


C++ QBitArray::size方法代码示例

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


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

示例1: haveChunks

void Tests::haveChunks()
{
   qDebug() << "===== haveChunks() =====";

   QList<Common::Hash> hashes;
   hashes
      << Common::Hash::fromStr("f6126deaa5e1d9692d54e3bef0507721372ee7f8") // "/sharedDirs/share3/aaaa bbbb cccc.txt"
      << Common::Hash::fromStr("4c24e58c47746ea04296df9342185d9b3a447899") // "/sharedDirs/share1/v.txt"
      << Common::Hash::fromStr("954531aef8ac193ad62f4de783da9d7e6ebd59dd") // "/sharedDirs/share1/y.txt" (deleted)
      << Common::Hash::fromStr("8374d82e993012aa23b293f319eef2c21d2da3b9"); // Random hash

   QBitArray expectedResult(hashes.size());
   expectedResult[0] = true;
   expectedResult[1] = true;
   expectedResult[2] = false;
   expectedResult[3] = false;

   QBitArray result = this->fileManager->haveChunks(hashes);
   QCOMPARE(result.size(), hashes.size());

   for (int i = 0; i < result.size(); i++)
   {
      QVERIFY(result[i] == expectedResult[i]);
      qDebug() << hashes[i].toStr() << " : " << (result[i] ? "Yes" : "No");
   }
}
开发者ID:PowerKiKi,项目名称:D-LAN,代码行数:26,代码来源:Tests.cpp

示例2: generate

    QBitArray generate(QBitArray aPayload, QBitArray aPoly)
    {
        using namespace NsConverter;

        const int n = aPoly.size();
        QBitArray shiftReg(n, false);

        for(int i=aPayload.size()-1; i>=0; i--)
        {
            if( shiftReg[n-1] != aPayload[i]  )
            {
                //qDebug()<<"--------------------";
                // qDebug()<<" poly "<<aPoly;
                //qDebug()<<" shiftxor before shift"<<shiftReg;
                shiftReg = shiftReg<<1;
                //qDebug()<<" shiftxor before xor"<<shiftReg;
                shiftReg ^= aPoly;
                // qDebug()<<" shiftxor after"<<shiftReg;
            }
            else
            {
                shiftReg = shiftReg<<1;
            }
        }

        return shiftReg;
    }
开发者ID:awaken1988,项目名称:RegisterAnalyzer,代码行数:27,代码来源:crcgenerator.cpp

示例3: dehuffman

QByteArray dehuffman(QByteArray data, MainWindow *mainWindow)
{
	QHash<quint8, QBitArray> codes;
	qint32 size;
	QBitArray bits;
	{
		QDataStream stream(data);
		stream >> codes >> size >> bits;
		Q_ASSERT(stream.status() == QDataStream::Ok);
	}

	QHash<QBitArray, quint8> table;
	for (int i = 0; i < tableSize; ++i)
		if (codes.contains(i))	table[codes[i]] = i;

	QByteArray result;
	result.reserve(data.size());

	int index = 0;
	for (int i = 0; i < size; ++i)
	{
		mainWindow->setProgress(qRound(static_cast<qreal>(100 * i) / size));

		QBitArray b;
		while (!table.contains(b))
		{
			b.resize(b.size() + 1);
			if (bits[index])	b.setBit(b.size() - 1);
			++index;
		}
		result.append(table[b]);
	}

	return result;
}
开发者ID:Etrnls,项目名称:etrnlabs,代码行数:35,代码来源:huffman.cpp

示例4: Number

 Number(const QBitArray &bitArray)
 {
     bits = bitArray.size();
     value = 0;
     for (quint8 i=0; i<bits; i++)
         if (bitArray.at(i)) value += 1 << (bits-i-1);
 }
开发者ID:jklontz,项目名称:AMillionRandomDigits,代码行数:7,代码来源:main.cpp

示例5: tryCompress

static QBitArray tryCompress(const QBitArray &data)
{
    qint32 closest = data.size();
    for (quint8 i=32; i>0; i--) {
        Count most, least;
        count(data, i, most, least);
        least = leastCommon(compress(data, most.number, Number()));
        if (least.number.bits >= most.number.bits) break;
        QBitArray compressed = compress(data, most.number, least.number);
        if (compressed.size() < data.size()) return compressed;
        closest = qMin(closest, compressed.size()-data.size());
    }

    qDebug("Could not compress, got as close as %d bits", closest);
    return data;
}
开发者ID:jklontz,项目名称:AMillionRandomDigits,代码行数:16,代码来源:main.cpp

示例6: sendPieceList

// Sends the complete list of pieces that we have downloaded.
void PeerWireClient::sendPieceList(const QBitArray &bitField)
{
    // The bitfield message may only be sent immediately after the
    // handshaking sequence is completed, and before any other
    // messages are sent.
    if (!sentHandShake)
        sendHandShake();

    // Don't send the bitfield if it's all zeros.
    if (bitField.count(true) == 0)
	return;

    int bitFieldSize = bitField.size();
    int size = (bitFieldSize + 7) / 8;
    QByteArray bits(size, '\0');
    for (int i = 0; i < bitFieldSize; ++i) {
        if (bitField.testBit(i)) {
            quint32 byte = quint32(i) / 8;
            quint32 bit = quint32(i) % 8;
            bits[byte] = uchar(bits.at(byte)) | (1 << (7 - bit));
        }
    }

    char message[] = {0, 0, 0, 1, 5};
    toNetworkData(bits.size() + 1, &message[0]);
    write(message, sizeof(message));
    write(bits);
}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:29,代码来源:peerwireclient.cpp

示例7: validateJointSelection

	bool ARehabMainWindow::validateJointSelection(void)
	{
		bool validate = true, someBitActive = false;
		//QBitArray nullBitArray(21, false);
		//QBitArray bitArray = jointSelectorWidget->getJointSelectorModel();
		QBitArray bitArray = jointSelectorWidget->getJointSelectorModel();

		for (unsigned int i = 0; i < bitArray.size(); ++i)
		{
			someBitActive |= jointSelectorWidget->getJointSelectorModel()[i];
		}

		if (!someBitActive)
		{			
			ui.lbValidationJoints->setPixmap(QPixmap(QString::fromUtf8(":/svg/bad.svg")));
			//ui.lbValidationJoints->show();
			validate = false;
		}
		else
		{
			this->arehabFileMetadata.jointsInvolved = this->jointSelectorWidget->getJointSelectorModel();
			ui.lbValidationJoints->setPixmap(QPixmap(QString::fromUtf8(":/svg/checked.svg")));
			//ui.lbValidationJoints->show();
		}
		return validate;
	}
开发者ID:JJ,项目名称:ARehab,代码行数:26,代码来源:ARehab_vTerapeuta.cpp

示例8: applyMaskWithInValues_helper

bool PropertyBitmaskConverter::applyMaskWithInValues_helper(QVariant &inVariant, QVariant &outVariant)
{
    bool ok(true);
    QBitArray inBitRepres = variantToBitArray(inVariant, ok);
    qDebug()<<"In value \t"<<inBitRepres;
    if (!ok)
        return ok;
    QBitArray outBitRepres = variantToBitArray(outVariant, ok);
    qDebug()<<"Out value \t"<<outBitRepres;
    if (!ok)
        return ok;
    Q_ASSERT(!_bitmaskFromInternal.isNull());
    QBitArray maskCopy = _bitmaskFromInternal;
    if (outBitRepres.count() != 0)
        maskCopy.truncate(outBitRepres.size());
    else
        outBitRepres.resize(maskCopy.count());
    inBitRepres.truncate(maskCopy.count());
    qDebug()<<"Mask (mod)\t"<<maskCopy;

    //! \todo optimize and beautify it
    if (inVariant.type() == QVariant::Bool)
        inBitRepres = maskCopy;
    else
        inBitRepres &= (maskCopy);//get only masked bits
    outBitRepres &= (~maskCopy);//clear mask bits
    outBitRepres |= inBitRepres;//set relevant bits from mask
    qDebug()<<"Out res\t"<<outBitRepres;

    return variantFromBitArray(outVariant, outBitRepres);
}
开发者ID:Krzysztow,项目名称:proto-gateway,代码行数:31,代码来源:propertyconverter.cpp

示例9: ShouldRevealNyms

  QBitArray BuddyMonitor::ShouldRevealNyms(const QBitArray &nyms)
  {
    if(m_min_anon == 0) {
      return nyms;
    }

    Q_ASSERT(nyms.size() == m_bp->GetCount());
    QList<QBitArray> member_set = m_member_set;
    QBitArray useful_members = GetUsefulMembers();
    QBitArray rv(nyms.size(), false);

    for(int idx = 0; idx < m_bp->GetCount(); idx++) {
      if(!nyms[idx]) {
        continue;
      }

      QBitArray new_set = m_nym_set[idx] & useful_members;
      if(new_set.count(true) < m_min_anon) {
        continue;
      }

      QList<QBitArray> t_member_set = member_set;
      bool bad = false;
      for(int jdx = 0; jdx < m_bp->GetCount(); jdx++) {
        if(useful_members[jdx]) {
          continue;
        }

        if(member_set[jdx][idx] && member_set[jdx].count(true) == m_min_anon) {
          bad = true;
          break;
        }

        member_set[jdx][idx] = false;
      }

      if(bad) {
        member_set = t_member_set;
      } else {
        rv[idx] = true;
      }
    }

    Q_ASSERT((nyms | rv) == nyms);
    Q_ASSERT(rv.size() <= nyms.size());
    return rv;
  }
开发者ID:ASchurman,项目名称:Dissent,代码行数:47,代码来源:BuddyMonitor.cpp

示例10: setParticleSelection

/******************************************************************************
* Replaces the particle selection.
******************************************************************************/
void ParticleSelectionSet::setParticleSelection(const PipelineFlowState& state, const QBitArray& selection, SelectionMode mode)
{
	// Make a backup of the old snapshot so it may be restored.
	if(dataset()->undoStack().isRecording())
		dataset()->undoStack().push(new ReplaceSelectionOperation(this));

	ParticlePropertyObject* identifierProperty = ParticlePropertyObject::findInState(state, ParticleProperty::IdentifierProperty);
	if(identifierProperty && useIdentifiers()) {
		OVITO_ASSERT(selection.size() == identifierProperty->size());
		_selection.clear();
		int index = 0;
		if(mode == SelectionReplace) {
			_selectedIdentifiers.clear();
			for(int id : identifierProperty->constIntRange()) {
				if(selection.testBit(index++))
					_selectedIdentifiers.insert(id);
			}
		}
		else if(mode == SelectionAdd) {
			for(int id : identifierProperty->constIntRange()) {
				if(selection.testBit(index++))
					_selectedIdentifiers.insert(id);
			}
		}
		else if(mode == SelectionSubtract) {
			for(int id : identifierProperty->constIntRange()) {
				if(selection.testBit(index++))
					_selectedIdentifiers.remove(id);
			}
		}
	}
	else {
		_selectedIdentifiers.clear();
		if(mode == SelectionReplace)
			_selection = selection;
		else if(mode == SelectionAdd) {
			_selection.resize(selection.size());
			_selection |= selection;
		}
		else if(mode == SelectionSubtract) {
			_selection.resize(selection.size());
			_selection &= ~selection;
		}
	}

	notifyDependents(ReferenceEvent::TargetChanged);
}
开发者ID:bitzhuwei,项目名称:OVITO_sureface,代码行数:50,代码来源:ParticleSelectionSet.cpp

示例11: toDecInt

int CompassPort::toDecInt(QBitArray bitdata)
{
    int res = 0;
    int k=1,s=0;

    if(bitdata[0] == true)
    {
        bitdata=~bitdata;
        k=-1;
        s=1;
    }

    for(int i = 0;i < bitdata.size();i++)
    {
        res+=pow(2,i)*bitdata[(bitdata.size()-1)-i];
    }
    return (res+s)*k;
}
开发者ID:NustyNUts,项目名称:MKF1,代码行数:18,代码来源:compassport.cpp

示例12: toDecInt

int Kompas::toDecInt(QBitArray bitdata)
{
    int res = 0;
    int k=1,s=0;

    if(bitdata[0] == true)
    {
        //bitdata=bitdata - QBitArray(16).setBit(15,true);
        bitdata=~bitdata;
        k=-1;
        s=1;
    }

    for(int i = 0;i < bitdata.size();i++)
    {
        res+=pow(2,i)*bitdata[(bitdata.size()-1)-i];
    }
    return (res+s)*k;
}
开发者ID:Navi-Dals,项目名称:Compass,代码行数:19,代码来源:kompas.cpp

示例13: serialize

quint32 CBerBitStringStorage::serialize(CBerByteArrayOutputStream& berOStream, QObject* obj)
{
	QBitArray BA = *ptrValue(obj, 3);

	quint32 codeLength = 0;

	for (qint32 i = BA.size()-1; i >= 0; --i)
	{
		quint8 data = (BA[i] == false) ? 0 : 0xFF;
		berOStream.write(data);
	}
	berOStream.write( (quint8) (BA.size()) );

	codeLength = BA.size() + 1;

	CBerLength::encodeLength(berOStream, codeLength);

	return codeLength;
}
开发者ID:Saotomych,项目名称:ASN1,代码行数:19,代码来源:berBitStringStorage.cpp

示例14: setFilterTypes

void EventsModel::setFilterTypes(const QBitArray &typemap)
{
    bool fast = true;

    if (!m_filter.types.isNull() && m_filter.types.size() == typemap.size())
    {
        for (int i = 0; i < typemap.size(); ++i)
        {
            if (typemap[i] && !m_filter.types[i])
            {
                fast = false;
                break;
            }
        }
    }

    m_filter.types = typemap;
    applyFilters(!fast);
}
开发者ID:ruminsam,项目名称:bluecherry-client,代码行数:19,代码来源:EventsModel.cpp

示例15: write

QString BaseStateAbstract::write(QBitArray barray)
{
    QString ret;
    for (int i = 0; i < barray.size(); i++) {
        if (barray.at(i))
            ret.append(B_ONE);
        else
            ret.append(B_ZERO);
    }

    return ret;
}
开发者ID:metrodango,项目名称:pip3line,代码行数:12,代码来源:basestateabstract.cpp


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