mirror of
https://github.com/aria2/aria2.git
synced 2025-04-05 21:47:37 +03:00
Moved piece statistics stuff to new PieceStatMan class. Refactored PieceSelector interface. * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/LongestSequencePieceSelector.cc * src/LongestSequencePieceSelector.h * src/Makefile.am * src/PieceSelector.h * src/PieceStatMan.cc * src/PieceStatMan.h * src/RarestPieceSelector.cc * src/RarestPieceSelector.h * src/RequestGroup.cc * test/DefaultPieceStorageTest.cc * test/InOrderPieceSelector.h * test/Makefile.am * test/PieceStatManTest.cc * test/RarestPieceSelectorTest.cc
26 lines
514 B
C++
26 lines
514 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
|
|
{
|
|
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_
|