| 1629 | |
| 1630 | |
| 1631 | Resources Resources::filter( |
| 1632 | const lambda::function<bool(const Resource&)>& predicate) const |
| 1633 | { |
| 1634 | Resources result; |
| 1635 | result.resourcesNoMutationWithoutExclusiveOwnership.reserve(this->size()); |
| 1636 | foreach ( |
| 1637 | const Resource_Unsafe& resource_, |
| 1638 | resourcesNoMutationWithoutExclusiveOwnership) { |
| 1639 | if (predicate(resource_->resource)) { |
| 1640 | // We `push_back()` here instead of `add()` (which is O(n)). `add()` is |
| 1641 | // not necessary because we assume all Resource objects are already |
| 1642 | // combined in `Resources` and `filter()` should only take away |
| 1643 | // resource objects. |
| 1644 | result.resourcesNoMutationWithoutExclusiveOwnership.push_back(resource_); |
| 1645 | } |
| 1646 | } |
| 1647 | return result; |
| 1648 | } |
| 1649 | |
| 1650 | |
| 1651 | hashmap<string, Resources> Resources::reservations() const |