2010-10-31 07:23:53 +00:00
|
|
|
#ifndef D_IN_ORDER_PIECE_SELECTOR_H
|
|
|
|
#define D_IN_ORDER_PIECE_SELECTOR_H
|
2009-05-06 07:49:22 +00:00
|
|
|
|
|
|
|
#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
|
|
|
|
{
|
|
|
|
for(size_t i = 0; i < nbits; ++i) {
|
|
|
|
if(bitfield::test(bitfield, nbits, i)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
index = i;
|
|
|
|
return true;
|
2009-05-06 07:49:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace aria2
|
|
|
|
|
2010-10-31 07:23:53 +00:00
|
|
|
#endif // D_IN_ORDER_PIECE_SELECTOR_H
|