mirror of
https://github.com/aria2/aria2.git
synced 2025-01-04 09:03:46 +00:00
27 lines
560 B
C++
27 lines
560 B
C++
#ifndef D_IN_ORDER_PIECE_SELECTOR_H
|
|
#define D_IN_ORDER_PIECE_SELECTOR_H
|
|
|
|
#include "PieceSelector.h"
|
|
#include "bitfield.h"
|
|
|
|
namespace aria2 {
|
|
|
|
class InorderPieceSelector : public PieceSelector {
|
|
public:
|
|
virtual bool select(size_t& index, const unsigned char* bitfield,
|
|
size_t nbits) const CXX11_OVERRIDE
|
|
{
|
|
for (size_t i = 0; i < nbits; ++i) {
|
|
if (bitfield::test(bitfield, nbits, i)) {
|
|
index = i;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
} // namespace aria2
|
|
|
|
#endif // D_IN_ORDER_PIECE_SELECTOR_H
|