| 1613 | |
| 1614 | |
| 1615 | Resources Resources::filter( |
| 1616 | const lambda::function<bool(const Resource&)>& predicate) const |
| 1617 | { |
| 1618 | Resources result; |
| 1619 | result.resourcesNoMutationWithoutExclusiveOwnership.reserve(this->size()); |
| 1620 | foreach ( |
| 1621 | const Resource_Unsafe& resource_, |
| 1622 | resourcesNoMutationWithoutExclusiveOwnership) { |
| 1623 | if (predicate(resource_->resource)) { |
| 1624 | // We `push_back()` here instead of `add()` (which is O(n)). `add()` is |
| 1625 | // not necessary because we assume all Resource objects are already |
| 1626 | // combined in `Resources` and `filter()` should only take away |
| 1627 | // resource objects. |
| 1628 | result.resourcesNoMutationWithoutExclusiveOwnership.push_back(resource_); |
| 1629 | } |
| 1630 | } |
| 1631 | return result; |
| 1632 | } |
| 1633 | |
| 1634 | |
| 1635 | hashmap<string, Resources> Resources::reservations() const |