本文整理汇总了C++中HashMap::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ HashMap::Clear方法的具体用法?C++ HashMap::Clear怎么用?C++ HashMap::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashMap
的用法示例。
在下文中一共展示了HashMap::Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildSpellCheckerMapLocked
ECode CTextServicesManagerService::BuildSpellCheckerMapLocked(
IContext* context,
List<AutoPtr<ISpellCheckerInfo> >& list,
HashMap<String, AutoPtr<ISpellCheckerInfo> >& map,
TextServicesSettings* settings)
{
// TODO
return NOERROR;
list.Clear();
map.Clear();
const AutoPtr<IPackageManager> pm;
context->GetPackageManager((IPackageManager**)&pm);
assert(pm != NULL);
AutoPtr<IObjectContainer> services;
AutoPtr<IIntent> intent;
Int32 currentUserId;
FAIL_RETURN(CIntent::New(String("android.service.textservice.SpellCheckerService"), (IIntent**)&intent));
settings->GetCurrentUserId(¤tUserId);
FAIL_RETURN(pm->QueryIntentServicesAsUser(intent, IPackageManager::GET_META_DATA, currentUserId, (IObjectContainer**)&services));
if (services != NULL) {
AutoPtr<IObjectEnumerator> enumerator;
services->GetObjectEnumerator((IObjectEnumerator**)&enumerator);
Boolean hasNext = FALSE;
while(enumerator->MoveNext(&hasNext), hasNext) {
AutoPtr<IResolveInfo> ri;
AutoPtr<IServiceInfo> si;
enumerator->Current((IInterface**)&ri);
assert(ri != NULL);
ri->GetServiceInfo((IServiceInfo**)&si);
String packageName, name, permission;
assert(si != NULL);
si->GetPackageName(&packageName);
si->GetName(&name);
si->GetPermission(&permission);
AutoPtr<IComponentName> compName;
CComponentName::New(packageName, name, (IComponentName**)&compName);
String strCompName;
compName->ToString(&strCompName);
if (!Elastos::Droid::Manifest::Permission::BIND_TEXT_SERVICE.Equals(permission)) {
Slogger::W(TAG, "Skipping text service %s : it does not require the permission: %s ", strCompName.string(), Elastos::Droid::Manifest::Permission::BIND_TEXT_SERVICE.string());
continue;
}
if (DBG) Slogger::D(TAG, "Add: %s", strCompName.string());
//try {
AutoPtr<ISpellCheckerInfo> sci;
// CSpellCheckerInfo::New(context, ri, (ISpellCheckerInfo**)&sci);
assert(0);
Int32 subtypeCount;
sci->GetSubtypeCount(&subtypeCount);
if (subtypeCount <= 0) {
Slogger::W(TAG, "Skipping text service %s : it does not contain subtypes.", strCompName.string());
continue;
}
list.PushBack(sci);
String sciId;
sci->GetId(&sciId);
map[sciId] = sci;
// } catch (XmlPullParserException e) {
// Slog.w(TAG, "Unable to load the spell checker " + compName, e);
// } catch (IOException e) {
// Slog.w(TAG, "Unable to load the spell checker " + compName, e);
// }
}
if (DBG) {
Slogger::D(TAG, "buildSpellCheckerMapLocked: %d, %d", list.GetSize(), map.GetSize());
}
}
return NOERROR;
}