本文整理汇总了C#中HashMap.get方法的典型用法代码示例。如果您正苦于以下问题:C# HashMap.get方法的具体用法?C# HashMap.get怎么用?C# HashMap.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashMap
的用法示例。
在下文中一共展示了HashMap.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getExtensionsForFragment
public HashMap<StyleExtensionMapEntry> getExtensionsForFragment(HtmlElement element)
{
var hashmap = new HashMap<StyleExtensionMapEntry>();
//We need to loop over all of the relevant entries in the map that define some behavior
var allEntries = map.getAllRandoriSelectorEntries();
for ( var i=0; i<allEntries.length; i++) {
JsArray<HtmlElement> implementingNodes = findChildNodesForCompoundSelector(element, allEntries[i]);
//For each of those entries, we need to see if we have any elements in this DOM fragment that implement any of those classes
for ( var j=0; j<implementingNodes.length; j++) {
var implementingElement = implementingNodes[ j ];
var value = hashmap.get( implementingElement );
if ( value == null ) {
//Get the needed entry
var extensionEntry = map.getExtensionEntry(allEntries[i]);
//give us a copy so we can screw with it at will
hashmap.put(implementingElement, extensionEntry.clone());
} else {
//We already have data for this node, so we need to merge the new data into the existing one
var extensionEntry = map.getExtensionEntry(allEntries[i]);
extensionEntry.mergeTo( (StyleExtensionMapEntry)value );
}
}
}
//return the hashmap which can be queried and applied to the Dom
return hashmap;
}
示例2: TestCache
public void TestCache() {
WeakCache cache = new WeakCache();
Dictionary map = new HashMap();
for(int i = 0; i < LOAD_COUNT; i++) {
String key = String.valueOf(i);
cache.cache(key, key);
map.put(key, key);
}
for(int i = 0; i < LOAD_COUNT; i++) {
String key = String.valueOf(i);
AssertEquals(cache.fetch(key), key);
AssertEquals(map.get(key), cache.fetch(key));
}
}
示例3: describeElement
public ElementDescriptor describeElement(HtmlElement element, HashMap<StyleExtensionMapEntry> possibleExtensions )
{
//This is purely an efficiency gain. By making a merged map for this one element, we stop everyone from cycling through
//every class on an element to pull out their own piece of data
var entry = possibleExtensions.get(element);
var descriptor = new ElementDescriptor {
context = element.getAttribute("data-context"),
behavior = element.hasAttribute("data-mediator") ? element.getAttribute("data-mediator") : element.getAttribute("data-behavior"),
fragment = element.getAttribute("data-fragment"),
formatter = element.getAttribute( "data-formatter" ),
validator = element.getAttribute( "data-validator" )
};
if ( entry != null ) {
if (descriptor.context == null) {
descriptor.context = entry.getExtensionValue("context");
}
if (descriptor.behavior == null) {
//mediator and behavior are really the same thing and hence mutually exclusive
descriptor.behavior = entry.hasExtensionType("mediator")?entry.getExtensionValue("mediator"):entry.getExtensionValue("behavior");
}
if (descriptor.fragment == null) {
descriptor.fragment = entry.getExtensionValue("fragment");
}
if (descriptor.formatter == null) {
descriptor.formatter = entry.getExtensionValue("formatter");
}
if (descriptor.validator == null) {
descriptor.validator = entry.getExtensionValue("validator");
}
}
return descriptor;
}
示例4: Main
static void Main(string[] args)
{
HashMap hm = new HashMap();
hm.put(3, 3);
hm.put(103, 4);
hm.put(203, 5);
hm.put(4, 44);
int k = hm.get(4);
int k1 = hm.get(203);
hm.delete(203);
int k2 = hm.get(203);
int k3 = hm.get(4);
int k4 = 10;
}