6 Block::Block(Byte
*data
, std::size_t data_size
) {
7 this->data
.reserve(data_size
);
9 for(std::size_t x
= 0; x
< data_size
; x
++) {
10 this->data
.push_back(data
[x
]);
14 void Block::remove(std::size_t from
, std::size_t to
) {
15 if(from
> get_size() || to
> get_size() || from
>= to
) return;
16 data
.erase(data
.begin()+from
, data
.begin()+to
);
19 Misc::SmartPointer
<Block
> Block::subset(std::size_t from
, std::size_t to
) const {
20 if(from
> get_size() || to
> get_size() || from
>= to
) return NULL
;
21 /* NOTE: this is rather inefficient, since the Block constuctor is copying this data again . . . */
22 std::vector
<Byte
> temp_data(data
.begin() + from
, data
.begin() + to
);
23 return new Block(&temp_data
[0], temp_data
.size());
26 } // namespace Monitor
27 } // namespace Aesalon