| 613 | } |
| 614 | |
| 615 | void ScriptList::RemoveTop(SQInteger count) |
| 616 | { |
| 617 | this->modifications++; |
| 618 | |
| 619 | if (!this->sort_ascending) { |
| 620 | this->Sort(this->sorter_type, !this->sort_ascending); |
| 621 | this->RemoveBottom(count); |
| 622 | this->Sort(this->sorter_type, !this->sort_ascending); |
| 623 | return; |
| 624 | } |
| 625 | |
| 626 | switch (this->sorter_type) { |
| 627 | default: NOT_REACHED(); |
| 628 | case SORT_BY_VALUE: |
| 629 | for (auto iter = this->values.begin(); iter != this->values.end(); iter = this->values.begin()) { |
| 630 | if (--count < 0) return; |
| 631 | this->RemoveItem(iter->second); |
| 632 | } |
| 633 | break; |
| 634 | |
| 635 | case SORT_BY_ITEM: |
| 636 | for (auto iter = this->items.begin(); iter != this->items.end(); iter = this->items.begin()) { |
| 637 | if (--count < 0) return; |
| 638 | this->RemoveItem(iter->first); |
| 639 | } |
| 640 | break; |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | void ScriptList::RemoveBottom(SQInteger count) |
| 645 | { |
no test coverage detected