本文整理汇总了C++中BitField::IsSet方法的典型用法代码示例。如果您正苦于以下问题:C++ BitField::IsSet方法的具体用法?C++ BitField::IsSet怎么用?C++ BitField::IsSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitField
的用法示例。
在下文中一共展示了BitField::IsSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DecreaseHave
void PieceManager::DecreaseHave(const BitField &remote_bitf)
{
for(size_t i = 0; i < remote_bitf.NBits(); ++i)
{
if(remote_bitf.IsSet(i))
{
DecreaseHave(i);
}
}
}
示例2: IncreaseHave
void PieceManager::IncreaseHave(const BitField &remote_bitf)
{
if(remote_bitf.NBits() != m_bitfield.NBits())
{
assert(0);
return;
}
for(size_t i = 0; i < remote_bitf.NBits(); ++i)
{
if(remote_bitf.IsSet(i))
{
IncreaseHave(i);
}
}
}
示例3: get_req_piece_rarely
bool PieceManager::get_req_piece_rarely(t_uint32 &piece_idx, const BitField &remote_own_pieces)
{
for(size_t i = 1; i < m_interests.size(); ++i)
{
for(size_t j = 0; j < m_interests[i].size(); ++j)
{
t_uint32 pidx = m_interests[i][j];
if(remote_own_pieces.IsSet(pidx) && m_pieces_info[pidx].state == P_FREE)
{
piece_idx = pidx;
return true;
}
}
}
return false;
}
示例4: get_req_in_downloading
bool PieceManager::get_req_in_downloading(SliceInfo &slice_info, const BitField &remote_own_pieces)
{
t_uint32 best_pidx = NONE_PIECE_INDEX;
t_uint32 best_num = 0;
DownloadingPiece *pdown = 0;
for(StartedPiecesMap::iterator it = m_started_pieces.begin(); it != m_started_pieces.end(); ++it)
{
t_uint32 pidx = it->second->GetPieceIdx();
assert(pidx < m_bitfield.NBits());
assert(m_pieces_info[pidx].state == P_DOWNLOADING);
if(remote_own_pieces.IsSet(pidx) && it->second->HasFreeSlice())
{
if(m_pieces_info[pidx].have > best_num)
{
best_pidx = pidx;
best_num = m_pieces_info[pidx].have;
pdown = it->second;
}
}
}
if(pdown != 0)
{
assert(best_num > 0);
bool res = pdown->GetRequest(slice_info);
assert(res);
return true;
} else
{
return false;
}
}