本文整理汇总了C++中CUInt128::GetBitNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ CUInt128::GetBitNumber方法的具体用法?C++ CUInt128::GetBitNumber怎么用?C++ CUInt128::GetBitNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUInt128
的用法示例。
在下文中一共展示了CUInt128::GetBitNumber方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
CContact *CRoutingZone::GetContact(const CUInt128& id) const throw()
{
if (IsLeaf()) {
return m_bin->GetContact(id);
} else {
CUInt128 distance = CKademlia::GetPrefs()->GetKadID();
distance ^= id;
return m_subZones[distance.GetBitNumber(m_level)]->GetContact(id);
}
}
示例2:
CContact *CRoutingZone::GetContact(const CUInt128 &uID) const
{
if (IsLeaf())
return m_pBin->GetContact(uID);
else{
CUInt128 uDistance;
CKademlia::GetPrefs()->GetKadID(&uDistance);
uDistance.Xor(uID);
return m_pSubZones[uDistance.GetBitNumber(m_uLevel)]->GetContact(uID);
}
}
示例3:
CUInt128::CUInt128(const CUInt128 &uValue, UINT uNumBits)
{
// Copy the whole ULONGs
UINT uNumULONGs = uNumBits / 32;
for (UINT iIndex=0; iIndex<uNumULONGs; iIndex++)
m_uData[iIndex] = uValue.m_uData[iIndex];
// Copy the remaining bits
for (UINT iIndex=(32*uNumULONGs); iIndex<uNumBits; iIndex++)
SetBitNumber(iIndex, uValue.GetBitNumber(iIndex));
// Pad with random bytes (Not seeding based on time to allow multiple different ones to be created in quick succession)
for (UINT iIndex=uNumBits; iIndex<128; iIndex++)
SetBitNumber(iIndex, (rand()%2));
}
示例4: GetClosestTo
void CRoutingZone::GetClosestTo(uint32 uMaxType, const CUInt128 &uTarget, const CUInt128 &uDistance, uint32 uMaxRequired, ContactMap *pmapResult, bool bEmptyFirst, bool bInUse) const
{
// If leaf zone, do it here
if (IsLeaf())
{
m_pBin->GetClosestTo(uMaxType, uTarget, uMaxRequired, pmapResult, bEmptyFirst, bInUse);
return;
}
// otherwise, recurse in the closer-to-the-target subzone first
int iCloser = uDistance.GetBitNumber(m_uLevel);
m_pSubZones[iCloser]->GetClosestTo(uMaxType, uTarget, uDistance, uMaxRequired, pmapResult, bEmptyFirst, bInUse);
// if still not enough tokens found, recurse in the other subzone too
if (pmapResult->size() < uMaxRequired)
m_pSubZones[1-iCloser]->GetClosestTo(uMaxType, uTarget, uDistance, uMaxRequired, pmapResult, false, bInUse);
}
示例5: GetClosestTo
void CRoutingZone::GetClosestTo(uint32_t maxType, const CUInt128& target, const CUInt128& distance, uint32_t maxRequired, ContactMap *result, bool emptyFirst, bool inUse) const
{
// If leaf zone, do it here
if (IsLeaf()) {
m_bin->GetClosestTo(maxType, target, maxRequired, result, emptyFirst, inUse);
return;
}
// otherwise, recurse in the closer-to-the-target subzone first
int closer = distance.GetBitNumber(m_level);
m_subZones[closer]->GetClosestTo(maxType, target, distance, maxRequired, result, emptyFirst, inUse);
// if still not enough tokens found, recurse in the other subzone too
if (result->size() < maxRequired) {
m_subZones[1-closer]->GetClosestTo(maxType, target, distance, maxRequired, result, false, inUse);
}
}