| 107 | // If container is NULL, this function is a no-op. |
| 108 | template <typename T> |
| 109 | void STLDeleteElements(T* container) { |
| 110 | if (!container) return; |
| 111 | auto it = container->begin(); |
| 112 | while (it != container->end()) { |
| 113 | auto temp = it; |
| 114 | ++it; |
| 115 | delete *temp; |
| 116 | } |
| 117 | container->clear(); |
| 118 | } |
| 119 | |
| 120 | // Given an STL container consisting of (key, value) pairs, STLDeleteValues |
| 121 | // deletes all the "value" components and clears the container. Does nothing in |