当前位置: 首页>>代码示例>>C++>>正文


C++ HashMap::contains方法代码示例

本文整理汇总了C++中HashMap::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ HashMap::contains方法的具体用法?C++ HashMap::contains怎么用?C++ HashMap::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HashMap的用法示例。


在下文中一共展示了HashMap::contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addAccessibilityNotificationHandler

void addAccessibilityNotificationHandler(AccessibilityNotificationHandler* notificationHandler)
{
    if (!notificationHandler)
        return;

#if PLATFORM(GTK)
    JSGlobalContextRef jsContext = webkit_web_frame_get_global_context(mainFrame);
#else
    JSContextRef jsContext = 0;
#endif
    if (!jsContext)
        return;

    JSValueProtect(jsContext, notificationHandler->notificationFunctionCallback());
    // Check if this notification handler is related to a specific element.
    if (notificationHandler->platformElement()) {
        if (notificationHandlers.contains(notificationHandler->platformElement())) {
            JSValueUnprotect(jsContext, notificationHandlers.find(notificationHandler->platformElement())->value->notificationFunctionCallback());
            notificationHandlers.remove(notificationHandler->platformElement());
        }
        notificationHandlers.add(notificationHandler->platformElement(), notificationHandler);
    } else {
        if (notificationHandlers.contains(GlobalNotificationKey)) {
            JSValueUnprotect(jsContext, notificationHandlers.find(GlobalNotificationKey)->value->notificationFunctionCallback());
            notificationHandlers.remove(GlobalNotificationKey);
        }
        notificationHandlers.add(GlobalNotificationKey, notificationHandler);
    }

    connectAccessibilityCallbacks();
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2:

TEST(TestHashMapCopyConstructor, copyHashMapHasSameData)
{
    HashMap first;
    first.add("Ford", "Tang");
    HashMap second = first;
    ASSERT_EQ(first.size(), second.size());
    ASSERT_EQ(first.contains("Ford"), second.contains("Ford"));
    ASSERT_EQ(first.value("Ford"), second.value("Ford"));
}
开发者ID:FordTang,项目名称:ICS45C_ProgrammingCplusplus,代码行数:9,代码来源:HashMapTests.cpp

示例3: testContains

static std::string testContains()
{
    HashMap<std::size_t,double> map;
    for(std::size_t ii = 1; ii != 100; ++ii) {
        map[ii] = 0;
        for(std::size_t jj = ii; jj; --jj) {
            if( !map.contains(jj) ) {
                return "Contains failed on inserted item.";
            }
        }
        for(std::size_t jj = 101; jj != 150; ++jj) {
            if( map.contains(jj) ) {
                return "Contains failed on uninserted item.";
            }
        }
    }
    return "";
}
开发者ID:staticimport,项目名称:promotelib,代码行数:18,代码来源:HashMapTest.cpp

示例4: integerObjectReference

ObjectReference BinaryPropertyListPlan::integerObjectReference(int integer) const
{
    ASSERT(integer >= 0);
    if (!integer) {
        ASSERT(m_integerZeroObjectReference != invalidObjectReference());
        return m_integerZeroObjectReference;
    }
    ASSERT(m_integers.contains(integer));
    return m_integers.get(integer);
}
开发者ID:JefferyJeffery,项目名称:webkit,代码行数:10,代码来源:BinaryPropertyList.cpp

示例5: adoptWK

TEST(WebKit2, WKRetainPtr)
{
    WKRetainPtr<WKStringRef> string1 = adoptWK(WKStringCreateWithUTF8CString("a"));
    WKRetainPtr<WKStringRef> string2 = adoptWK(WKStringCreateWithUTF8CString("a"));
    WKRetainPtr<WKStringRef> string3 = adoptWK(WKStringCreateWithUTF8CString("a"));
    WKRetainPtr<WKStringRef> string4 = adoptWK(WKStringCreateWithUTF8CString("a"));

    HashMap<WKRetainPtr<WKStringRef>, int> map;

    map.set(string2, 2);
    map.set(string1, 1);

    EXPECT_TRUE(map.contains(string1));
    EXPECT_TRUE(map.contains(string2));
    EXPECT_FALSE(map.contains(string3));
    EXPECT_FALSE(map.contains(string4));

    EXPECT_EQ(1, map.get(string1));
    EXPECT_EQ(2, map.get(string2));
}
开发者ID:edcwconan,项目名称:webkit,代码行数:20,代码来源:WKRetainPtr.cpp

示例6: forClipboard

DataObjectGtk* DataObjectGtk::forClipboard(GtkClipboard* clipboard)
{
    static HashMap<GtkClipboard*, RefPtr<DataObjectGtk> > objectMap;

    if (!objectMap.contains(clipboard)) {
        RefPtr<DataObjectGtk> dataObject = DataObjectGtk::create();
        objectMap.set(clipboard, dataObject);
        return dataObject.get();
    }

    HashMap<GtkClipboard*, RefPtr<DataObjectGtk> >::iterator it = objectMap.find(clipboard);
    return it->value.get();
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:13,代码来源:DataObjectGtk.cpp

示例7:

// Test string version.
TEST(HashTest, STRINGHash) {				
	using namespace eoaix;				
	HashMap<std::string, TestKey> htable;			
	TestKey t1(1, "1str");					
	TestKey t2(2, "2str");					
	TestKey t4(4, "4str");					
	htable.insert(std::string("2"), t2);				
	htable.insert(std::string("1"), t1);				
	TestKey* t3 = htable.find_val(std::string("1"));	
	EXPECT_EQ(t3->toString(), t1.toString());	
	EXPECT_EQ(htable.contains(std::string("1")), true);	
	EXPECT_EQ(htable.contains(std::string("4")), false) << "htable.contains(t4) != true\n";	
}	
开发者ID:rt77789,项目名称:basic_tool_lib,代码行数:14,代码来源:test_hash.cpp

示例8: loadMappings

void Keymap::loadMappings(const HardwareInputSet *hwKeys) {
	if (!_configDomain)
		return;

	if (_actions.empty())
		return;

	Common::KeymapperDefaultBindings *defaults = g_system->getKeymapperDefaultBindings();

	HashMap<String, const HardwareInput *> mappedInputs;
	List<Action*>::iterator it;
	String prefix = KEYMAP_KEY_PREFIX + _name + "_";

	for (it = _actions.begin(); it != _actions.end(); ++it) {
		Action* ua = *it;
		String actionId(ua->id);
		String confKey = prefix + actionId;

		String hwInputId = _configDomain->getVal(confKey);

		bool defaulted = false;
		// fall back to the platform-specific defaults
		if (hwInputId.empty() && defaults) {
			hwInputId = defaults->getDefaultBinding(_name, actionId);
			if (!hwInputId.empty())
				defaulted = true;
		}
		// there's no mapping
		if (hwInputId.empty())
			continue;

		const HardwareInput *hwInput = hwKeys->findHardwareInput(hwInputId.c_str());

		if (!hwInput) {
			warning("HardwareInput with ID '%s' not known", hwInputId.c_str());
			continue;
		}

		if (defaulted) {
			if (mappedInputs.contains(hwInputId)) {
				debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the hardware input is in use", confKey.c_str(), hwInputId.c_str());
				continue;
			}
			warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwInputId.c_str());
		}

		mappedInputs.setVal(hwInputId, hwInput);
		// map the key
		ua->mapInput(hwInput);
	}
}
开发者ID:Bundesdrucker,项目名称:scummvm,代码行数:51,代码来源:keymap.cpp

示例9: deref

inline void CalculationValueMap::deref(unsigned handle)
{
    ASSERT(m_map.contains(handle));

    auto it = m_map.find(handle);
    if (it->value.referenceCountMinusOne) {
        --it->value.referenceCountMinusOne;
        return;
    }

    // The adoptRef here is balanced by the leakRef in the insert member function.
    Ref<CalculationValue> value { adoptRef(*it->value.value) };

    m_map.remove(it);
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:15,代码来源:Length.cpp

示例10: customSerializeResolvingVariables

String CSSPrimitiveValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
{
    if (isVariableName() && variables.contains(m_value.string))
        return variables.get(m_value.string);
    if (CSSCalcValue* calcValue = cssCalcValue())
        return calcValue->customSerializeResolvingVariables(variables);
    if (Pair* pairValue = getPairValue())
        return pairValue->serializeResolvingVariables(variables);
    if (Rect* rectVal = getRectValue())
        return rectVal->serializeResolvingVariables(variables);
    if (Quad* quadVal = getQuadValue())
        return quadVal->serializeResolvingVariables(variables);
    if (CSSBasicShape* shapeValue = getShapeValue())
        return shapeValue->serializeResolvingVariables(variables);
    return customCssText();
}
开发者ID:fmalita,项目名称:webkit,代码行数:16,代码来源:CSSPrimitiveValue.cpp

示例11: setPluginLoadClientPolicy

void WebProcessPool::setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy policy, const String& host, const String& bundleIdentifier, const String& versionString)
{
#if ENABLE(NETSCAPE_PLUGIN_API)
    HashMap<String, HashMap<String, uint8_t>> policiesByIdentifier;
    if (m_pluginLoadClientPolicies.contains(host))
        policiesByIdentifier = m_pluginLoadClientPolicies.get(host);

    HashMap<String, uint8_t> versionsToPolicies;
    if (policiesByIdentifier.contains(bundleIdentifier))
        versionsToPolicies = policiesByIdentifier.get(bundleIdentifier);

    versionsToPolicies.set(versionString, policy);
    policiesByIdentifier.set(bundleIdentifier, versionsToPolicies);
    m_pluginLoadClientPolicies.set(host, policiesByIdentifier);
#endif

    sendToAllProcesses(Messages::WebProcess::SetPluginLoadClientPolicy(policy, host, bundleIdentifier, versionString));
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例12: constructFamilyFontFaces

static Vector<Ref<CSSFontFace>> constructFamilyFontFaces(const String& familyName, HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash>& locallyInstalledFontFaces)
{
    auto result = Vector<Ref<CSSFontFace>>();

    ASSERT(!locallyInstalledFontFaces.contains(familyName));

    Vector<FontTraitsMask> traitsMasks = FontCache::singleton().getTraitsInFamily(familyName);
    if (!traitsMasks.isEmpty()) {
        Vector<Ref<CSSFontFace>> faces = { };
        for (auto mask : traitsMasks) {
            Ref<CSSFontFace> face = CSSFontFace::create(mask, nullptr, true);
            face->addSource(std::make_unique<CSSFontFaceSource>(familyName));
            ASSERT(face->isValid());
            faces.append(WTF::move(face));
        }
        locallyInstalledFontFaces.add(familyName, WTF::move(faces));
    }
    return result;
}
开发者ID:xiaoyanzheng,项目名称:webkit,代码行数:19,代码来源:CSSFontSelector.cpp

示例13: CSSStyleDeclaration

CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const CSSProperty* const * properties, int numProperties)
    : CSSStyleDeclaration(parent)
    , m_node(0)
    , m_strictParsing(!parent || parent->useStrictParsing())
#ifndef NDEBUG
    , m_iteratorCount(0)
#endif
{
    m_properties.reserveInitialCapacity(numProperties);
    HashMap<int, bool> candidates;
    for (int i = 0; i < numProperties; ++i) {
        const CSSProperty *property = properties[i];
        ASSERT(property);
        bool important = property->isImportant();
        if (candidates.contains(property->id())) {
            if (!important && candidates.get(property->id()))
                continue;
            removeProperty(property->id(), false);
        }
        m_properties.append(*property);
        candidates.set(property->id(), important);
    }
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例14: mimeTypeForExtension

static String mimeTypeForExtension(const String& file)
{
    static HashMap<String, String, CaseFoldingHash> extensionToMime;
    if (extensionToMime.isEmpty()) {
        extensionToMime.set("txt", "text/plain");
        extensionToMime.set("html", "text/html");
        extensionToMime.set("htm", "text/html");
        extensionToMime.set("png", "image/png");
        extensionToMime.set("jpeg", "image/jpeg");
        extensionToMime.set("jpg", "image/jpeg");
        extensionToMime.set("gif", "image/gif");
        extensionToMime.set("ico", "image/x-icon");
        extensionToMime.set("js", "text/javascript");
    }
    int dot = file.reverseFind('.');
    String mime("text/plain");
    if (dot != -1) {
        String ext = file.substring(dot + 1);
        if (extensionToMime.contains(ext))
            mime = extensionToMime.get(ext);
    }
    return mime;
}
开发者ID:ACSOP,项目名称:android_external_webkit,代码行数:23,代码来源:Intercept.cpp

示例15:

static void testU32Map()
{
	HashMap<U32, U32> map;

	enum { maxI = 1024 * 1024 };

	for(Uptr i = 0;i < maxI;++i)
	{
		errorUnless(!map.contains(U32(i)));
	}

	errorUnless(map.size() == 0);
	for(Uptr i = 0;i < maxI;++i)
	{
		errorUnless(!map.contains(U32(i)));
		errorUnless(!map.get(U32(i)));
		errorUnless(map.add(U32(i),U32(i * 2)));
		errorUnless(map.contains(U32(i)));
		errorUnless(map.get(U32(i)));
		errorUnless(*map.get(U32(i)) == U32(i * 2));
		errorUnless(map.size() == i + 1);
	}

	for(Uptr i = 0;i < maxI;++i)
	{
		errorUnless(map.contains(U32(i)));
		errorUnless(map.remove(U32(i)));
		errorUnless(!map.contains(U32(i)));
		errorUnless(map.size() == maxI - i - 1);
	}

	for(Uptr i = 0;i < maxI;++i)
	{
		errorUnless(!map.contains(U32(i)));
	}
}
开发者ID:ramtej,项目名称:WAVM,代码行数:36,代码来源:HashMapTest.cpp


注:本文中的HashMap::contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。