diff --git a/kernel/drivertools.cc b/kernel/drivertools.cc index 27ebd20b284..805532e9b29 100644 --- a/kernel/drivertools.cc +++ b/kernel/drivertools.cc @@ -910,6 +910,38 @@ bool DriveChunkMultiple::try_append(DriveChunkMultiple const &chunk) return true; } +DriveChunkMultiple::DriveChunkMultiple(DriveBitMultiple const &bit) + : width_(1) +{ + for (auto const &bit : bit.multiple()) + multiple_.emplace(bit); +} + +pool const &DriveChunkMultiple::multiple() const +{ + return multiple_; +} + +int DriveChunkMultiple::size() const { return width_; } + + +bool DriveChunkMultiple::operator==(const DriveChunkMultiple &other) const +{ + return width_ == other.width_ && multiple_ == other.multiple_; +} + +bool DriveChunkMultiple::operator<(const DriveChunkMultiple &other) const +{ + if (multiple_.size() < other.multiple_.size()) + multiple_.sort(); + return false; // TODO: implement, canonicalize order +} + +unsigned int DriveChunkMultiple::hash() const +{ + return mkhash(width_, multiple_.hash()); +} + bool DriveChunk::can_append(DriveBit const &bit) const { if (size() == 0) diff --git a/kernel/drivertools.h b/kernel/drivertools.h index 4f6c7a7befe..51b72c49162 100644 --- a/kernel/drivertools.h +++ b/kernel/drivertools.h @@ -265,47 +265,23 @@ struct DriveChunkMarker struct DriveChunkMultiple { private: - mutable pool multiple_; - int width_; + mutable pool multiple_; + int width_; public: - pool const &multiple() const { return multiple_; } + pool const &multiple() const; - DriveChunkMultiple(DriveBitMultiple const &bit) : width_(1) { - for (auto const &bit : bit.multiple()) - multiple_.emplace(bit); - } - - int size() const { return width_; } - - DriveBitMultiple operator[](int i) const; - - bool can_append(DriveBitMultiple const &bit) const; - - bool try_append(DriveBitMultiple const &bit); + DriveChunkMultiple(DriveBitMultiple const &bit); - - bool can_append(DriveChunkMultiple const &bit) const; - - bool try_append(DriveChunkMultiple const &bit); - - bool operator==(const DriveChunkMultiple &other) const - { - return width_ == other.width_ && multiple_ == other.multiple_; - } - - bool operator<(const DriveChunkMultiple &other) const - { - if (multiple_.size() < other.multiple_.size()) - - multiple_.sort(); - return false; // TODO implement, canonicalize order - } - - unsigned int hash() const - { - return mkhash(width_, multiple_.hash()); - } + int size() const; + DriveBitMultiple operator[](int i) const; + bool can_append(DriveBitMultiple const &bit) const; + bool try_append(DriveBitMultiple const &bit); + bool can_append(DriveChunkMultiple const &bit) const; + bool try_append(DriveChunkMultiple const &bit); + bool operator==(const DriveChunkMultiple &other) const; + bool operator<(const DriveChunkMultiple &other) const; + unsigned int hash() const; }; struct DriveChunk