本文整理汇总了C++中HashMap::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ HashMap::Find方法的具体用法?C++ HashMap::Find怎么用?C++ HashMap::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashMap
的用法示例。
在下文中一共展示了HashMap::Find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetContext
Context* GetContext(lua_State* L)
{
HashMap<void*, Context*>::ConstIterator i = contextMapping.Find(L);
if (i == contextMapping.End())
{
lua_State* L1 = lua_getmainthread(L);
return (L == L1) ? 0 : GetContext(L1);
}
return i->second_;
}
示例2: if
ECode CWifiP2pDnsSdServiceResponse::ReadDnsName(
/* [in] */ IDataInput* idi,
/* [out] */ String* dnsName)
{
VALIDATE_NOT_NULL(dnsName);
*dnsName = String(NULL);
StringBuilder sb;
// copy virtual memory packet.
HashMap<Int32, String> vmpack;
HashMap<Int32, String>::Iterator it;
if (!mDnsQueryName.IsNull()) {
vmpack[0x27] = mDnsQueryName;
}
// try {
Int32 i, temp;
while (TRUE) {
FAIL_RETURN(idi->ReadUnsignedByte(&i));
if (i == 0x00) {
*dnsName = sb.ToString();
return NOERROR;
}
else if (i == 0xc0) {
// refer to pointer.
FAIL_RETURN(idi->ReadUnsignedByte(&temp));
it = vmpack.Find(temp);
if (it == vmpack.End()) {
//invalid.
return NOERROR;
}
sb += it->mSecond;
*dnsName = sb.ToString();
return NOERROR;
}
else {
AutoPtr<ArrayOf<Byte> > data = ArrayOf<Byte>::Alloc(i);
if (data == NULL) return E_OUT_OF_MEMORY;
FAIL_RETURN(idi->ReadFully((ArrayOf<Byte>*)data));
sb += String((const char *)data->GetPayload());
sb += ".";
}
}
// catch (IOException e) {
// e.printStackTrace();
// }
return NOERROR;
}
示例3: RemoveNamedAttribute
void RemoveNamedAttribute(HashMap<StringHash, Vector<AttributeInfo> >& attributes, StringHash objectType, const char* name)
{
HashMap<StringHash, Vector<AttributeInfo> >::Iterator i = attributes.Find(objectType);
if (i == attributes.End())
return;
Vector<AttributeInfo>& infos = i->second_;
for (Vector<AttributeInfo>::Iterator j = infos.Begin(); j != infos.End(); ++j)
{
if (!j->name_.Compare(name, true))
{
infos.Erase(j);
break;
}
}
// If the vector became empty, erase the object type from the map
if (infos.Empty())
attributes.Erase(i);
}