Browse Source

CPP: Internal function rename (CompareFirst -> OrderByFirst).

pull/567/head
Philip Liard 15 years ago
committed by Mihaela Rosca
parent
commit
ec308eb9e2
3 changed files with 35 additions and 9 deletions
  1. +3
    -2
      cpp/src/phonenumberutil.cc
  2. +0
    -7
      cpp/src/phonenumberutil.h
  3. +32
    -0
      cpp/src/stl_util.h

+ 3
- 2
cpp/src/phonenumberutil.cc View File

@ -39,6 +39,7 @@
#include "phonenumber.pb.h"
#include "regexp_adapter.h"
#include "regexp_cache.h"
#include "stl_util.h"
#include "stringutil.h"
#include "utf/unicodetext.h"
#include "utf/utf.h"
@ -709,7 +710,7 @@ PhoneNumberUtil::PhoneNumberUtil()
// Sort all the pairs in ascending order according to country calling code.
sort(country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end(),
CompareFirst());
OrderByFirst());
InitializeStaticMapsAndSets();
}
@ -1200,7 +1201,7 @@ void PhoneNumberUtil::GetRegionCodesForCountryCallingCode(
pair<ConstIterator, ConstIterator> range = equal_range(
country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end(),
target_pair, CompareFirst());
target_pair, OrderByFirst());
if (range.first != range.second) {
region_codes->insert(region_codes->begin(),
range.first->second->begin(),


+ 0
- 7
cpp/src/phonenumberutil.h View File

@ -521,13 +521,6 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
// achieve better performance.
scoped_ptr<vector<IntRegionsPair> > country_calling_code_to_region_code_map_;
struct CompareFirst {
bool operator()(const IntRegionsPair& p1,
const IntRegionsPair& p2) const {
return p1.first < p2.first;
}
};
// The set of regions that share country calling code 1.
scoped_ptr<set<string> > nanpa_regions_;
static const int kNanpaCountryCode = 1;


+ 32
- 0
cpp/src/stl_util.h View File

@ -0,0 +1,32 @@
// Copyright (C) 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef I18N_PHONENUMBERS_STL_UTIL_H_
#define I18N_PHONENUMBERS_STL_UTIL_H_
namespace i18n {
namespace phonenumbers {
// Compares the first attribute of two pairs.
struct OrderByFirst {
template <typename T>
bool operator()(const T& p1, const T& p2) const {
return p1.first < p2.first;
}
};
} // namespace phonenumbers
} // namespace i18n
#endif // I18N_PHONENUMBERS_STL_UTIL_H_

Loading…
Cancel
Save