OLD | NEW |
(Empty) | |
| 1 // Copyright (C) 2011 Google Inc. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #ifndef I18N_PHONENUMBERS_STL_UTIL_H_ |
| 16 #define I18N_PHONENUMBERS_STL_UTIL_H_ |
| 17 |
| 18 namespace i18n { |
| 19 namespace phonenumbers { |
| 20 |
| 21 // Compares the first attribute of two pairs. |
| 22 struct OrderByFirst { |
| 23 template <typename T> |
| 24 bool operator()(const T& p1, const T& p2) const { |
| 25 return p1.first < p2.first; |
| 26 } |
| 27 }; |
| 28 |
| 29 // Deletes the second attribute (pointer type expected) of the pairs contained |
| 30 // in the provided range. |
| 31 template <typename ForwardIterator> |
| 32 void STLDeleteContainerPairSecondPointers(const ForwardIterator& begin, |
| 33 const ForwardIterator& end) { |
| 34 for (ForwardIterator it = begin; it != end; ++it) { |
| 35 delete it->second; |
| 36 } |
| 37 } |
| 38 |
| 39 } // namespace phonenumbers |
| 40 } // namespace i18n |
| 41 |
| 42 #endif // I18N_PHONENUMBERS_STL_UTIL_H_ |
OLD | NEW |