| 1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef FLUTTER_FML_CONTAINER_H_ |
| 6 | #define FLUTTER_FML_CONTAINER_H_ |
| 7 | |
| 8 | #include <functional> |
| 9 | #include <map> |
| 10 | |
| 11 | namespace fml { |
| 12 | |
| 13 | template < |
| 14 | class Collection = |
| 15 | std::unordered_map<class Key, class Value, class Hash, class Equal>> |
| 16 | void erase_if(Collection& container, |
| 17 | std::function<bool(typename Collection::iterator)> predicate) { |
| 18 | auto it = container.begin(); |
| 19 | while (it != container.end()) { |
| 20 | if (predicate(it)) { |
| 21 | it = container.erase(it); |
| 22 | continue; |
| 23 | } |
| 24 | it++; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | } // namespace fml |
| 29 | |
| 30 | #endif // FLUTTER_FML_CONTAINER_H_ |
| 31 | |