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


C++ KeySet::insert方法代码示例

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


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

示例1: keys

/* ************************************************************************* */
GaussianFactorGraph::Keys GaussianFactorGraph::keys() const {
    KeySet keys;
    BOOST_FOREACH(const sharedFactor& factor, *this)
    if (factor)
        keys.insert(factor->begin(), factor->end());
    return keys;
}
开发者ID:exoter-rover,项目名称:slam-gtsam,代码行数:8,代码来源:GaussianFactorGraph.cpp

示例2:

void object::test<4>()
{
    Unkeyed one, two, three;
    typedef std::set<Unkeyed*> KeySet;

    KeySet instances;
    instances.insert(&one);
    instances.insert(&two);
    instances.insert(&three);

    for (Unkeyed::instance_iter ii(Unkeyed::beginInstances()), iend(Unkeyed::endInstances()); ii != iend; ++ii)
    {
        Unkeyed& ref = *ii;
        ensure_equals("spurious instance", instances.erase(&ref), 1);
    }

    ensure_equals("unreported instance", instances.size(), 0);
}
开发者ID:HizWylder,项目名称:GIS,代码行数:18,代码来源:llinstancetracker_test.cpp

示例3: GetAvailableKeys

KeySet GetAvailableKeys(KeyCount const& kc)
{
  KeySet available;
  for (auto k : kc) {
    if (k.second <= 0) {
      continue;
    }
    available.insert(k.first);
  }
  return available;
}
开发者ID:aardvarkk,项目名称:mixant,代码行数:11,代码来源:main.cpp

示例4: aKey

int
main(int argc, const char** argv)
{
	//WDBG_INIT(WDBG_LIBLOW, "CryptTest", NULL, "E:\\Logs");

	{
		cout << endl << "Testing Random Number Generator..." << endl;
		for (int i=1; i <= 100; i++)
		{
			unsigned short aShort = Randomizer::GetShort();
			cout << std::hex << aShort << std::dec << "  ";
			if ((i % 5) == 0) cout << endl;
		}
		cout << endl;
	}

	{
		cout << endl << "Testing Key Classes..." << endl;
		KeySet aKeySet;
		aKeySet.insert(new BFSymmetricKey(CryptKeyBase::KEYLEN_DEF));
		aKeySet.insert(new BFSymmetricKey(4));
		BFSymmetricKey aKey(12);
		aKeySet.insert(new BFSymmetricKey(aKey.GetKeyLen(), aKey.GetKey()));

		aKeySet.insert(new EGPrivateKey(CryptKeyBase::KEYLEN_DEF));
		aKeySet.insert(new EGPrivateKey(4));
		EGPrivateKey aPvKey(12);
		EGPrivateKey aPvKey1(0);
		aKeySet.insert(new EGPrivateKey(aPvKey.GetKeyLen(), aPvKey.GetKey()));
		aKeySet.insert(new EGPrivateKey(aPvKey1));

		const EGPublicKey& aPubKey = dynamic_cast<const EGPublicKey&>(aPvKey1.GetPublicKey());
		aKeySet.insert(new EGPublicKey(aPvKey));
		aKeySet.insert(new EGPublicKey(aPubKey));

		// Output keys
		KeySet::iterator anItr(aKeySet.begin());
		for (int i=1; anItr != aKeySet.end(); i++)
		{
			cout << "Key " << i << ":  " << *(*anItr) << endl;
			delete *anItr;
			anItr = aKeySet.erase(anItr);
		}
		cout << endl;
	}

	{
		cout << endl << "Testing SymmetricCrypt..." << endl;
		BFSymmetricKey* myKey  = new BFSymmetricKey(8);
		BFSymmetricKey* badKey = new BFSymmetricKey(12);
		char* iStr = "Mike has no life!";
		BFSymmetricKey::CryptReturn encrypt(myKey->Encrypt(reinterpret_cast<unsigned char*>(iStr), strlen(iStr)+1));
		BFSymmetricKey::CryptReturn decrypt(myKey->Decrypt(encrypt.first, encrypt.second));
		cout << "Input:  " << iStr << endl;
		cout << "Output: " << reinterpret_cast<const char*>(decrypt.first ? decrypt.first : (const unsigned char*)"NULL") << endl;
		delete encrypt.first;  delete decrypt.first;
		delete myKey;
		delete badKey;
	}

	{
		cout << endl << "Testing ElGamal Crypt..." << endl;
		EGPrivateKey* myPrivKey = new EGPrivateKey(8);
		EGPrivateKey* badKey = new EGPrivateKey(12);
		EGPublicKey*  myPubKey  = new EGPublicKey(*myPrivKey);
		char* iStr = "Mike has no life!";
		EGPublicKey::CryptReturn  encrypt(myPubKey->Encrypt(reinterpret_cast<unsigned char*>(iStr), strlen(iStr)+1));
		EGPrivateKey::CryptReturn decrypt(myPrivKey->Decrypt(encrypt.first, encrypt.second));
		cout << "Input:  " << iStr << endl;
		cout << "Output: " << reinterpret_cast<const char*>(decrypt.first ? decrypt.first : (const unsigned char*)"NULL") << endl;
		delete encrypt.first;  delete decrypt.first;
		delete myPrivKey;
		delete myPubKey;
		delete badKey;
	}

	{
		cout << endl << "Testing ElGamal Sigs..." << endl;
		EGPrivateKey* myPrivKey = new EGPrivateKey(8);
		EGPrivateKey* badKey = new EGPrivateKey(12);
		EGPublicKey*  myPubKey  = new EGPublicKey(*myPrivKey);
		char* iStr = "Mike has no life!";
		EGPrivateKey::CryptReturn sig(myPrivKey->Sign(reinterpret_cast<unsigned char*>(iStr), strlen(iStr)+1));
		int tstSig = myPubKey->Verify(sig.first, sig.second, reinterpret_cast<unsigned char*>(iStr), strlen(iStr)+1);
		cout << "Msg:    " << iStr << "  sigLen=" << sig.second << endl;
		cout << "Verify: " << (tstSig ? "TRUE" : "FALSE") << endl;
		delete sig.first;
		delete myPrivKey;
		delete myPubKey;
	}

	return 0;
}
开发者ID:vgck,项目名称:opendr2,代码行数:93,代码来源:cryptTest.cpp


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