本文整理汇总了C#中System.Collections.Hashtable.AsReadOnlyDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.AsReadOnlyDictionary方法的具体用法?C# Hashtable.AsReadOnlyDictionary怎么用?C# Hashtable.AsReadOnlyDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Hashtable
的用法示例。
在下文中一共展示了Hashtable.AsReadOnlyDictionary方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNamespaceToVariablesAllocatedTherein
/// <returns>Hashtable<Namespace,ArrayList<TerminalName>></returns>
private static ReadOnlyDictionary CreateNamespaceToVariablesAllocatedTherein(IEnumerable liveLocalNonParameterVariableNames)
{
var result=new Hashtable();
foreach(TerminalName name in liveLocalNonParameterVariableNames) {
result.LookupOrCreateArrayList(name.Namespace).Add(name);
}
return result.AsReadOnlyDictionary();
}
示例2: EstablishRegisterAllocationCounts
private static ReadOnlyDictionary EstablishRegisterAllocationCounts(ReadOnlyDictionary depthToNamespaces, int freeRegisterMask,
IEnumerable leaves, int maxDepth, ReadOnlyDictionary nsToLiveVars)
{
var initialBudget=0;
while(freeRegisterMask>0) {
++initialBudget;
freeRegisterMask&=(freeRegisterMask-1);
}
var budget=new Hashtable(); //Hashtable<Namespace,int>
foreach(Namespace ns in leaves) {
budget[ns]=initialBudget;
}
var result=new Hashtable(); //Hashtable<Namespace,int>
object boxedMaxValue=int.MaxValue;
for(var depth=maxDepth; depth>=0; --depth) {
var itemsToProcess=(ArrayList)depthToNamespaces[depth];
foreach(Namespace ns in itemsToProcess) {
var capacity=(int)budget[ns];
var liveVars=(ArrayList)nsToLiveVars[ns];
var requested=liveVars!=null ? liveVars.Count : 0;
var granted=Math.Min(capacity, requested);
var remaining=capacity-granted;
result.Add(ns, granted);
result[ns]=granted;
//now forward the budget to my parent
var inner=ns.Inner;
if(inner!=null) {
var existingBudget=(int)(budget[inner] ?? boxedMaxValue);
var newBudget=Math.Min(existingBudget, remaining);
budget[inner]=newBudget;
}
}
}
return result.AsReadOnlyDictionary();
}
示例3: FindLeaves
/// <summary>
/// Find the namespace leaves
/// </summary>
/// <returns>Hashtable<Namespace,null>></returns>
private static ReadOnlyDictionary FindLeaves(IEnumerable liveLocalNonParameterVariableNames)
{
var leaves=new Hashtable(); //Hashtable<Namespace,null>
foreach(TerminalName name in liveLocalNonParameterVariableNames) {
leaves[name.Namespace]=null;
}
foreach(TerminalName name in liveLocalNonParameterVariableNames) {
for(var ns=name.Namespace.Inner; ns!=null; ns=ns.Inner) {
leaves.Remove(ns);
}
}
return leaves.AsReadOnlyDictionary();
}
示例4: MakeDepthToNamespaces
/// <summary>
/// Basically: liveVariables.Select(lv=>lv.Namespace).GroupBy(ns=>ns.Depth)
/// </summary>
/// <returns>Hashtable<int,ArrayList<Namespace>></returns>
private static ReadOnlyDictionary MakeDepthToNamespaces(IEnumerable liveLocalNonParameterVariableNames, out int maxDepth)
{
var result=new Hashtable();
var beenHere=new Hashtable();
maxDepth=-1;
foreach(TerminalName name in liveLocalNonParameterVariableNames) {
var ns=name.Namespace;
maxDepth=Math.Max(maxDepth, ns.Depth);
while(ns!=null) {
if(beenHere.Contains(ns)) {
break;
}
beenHere.Add(ns, null);
result.LookupOrCreateArrayList(ns.Depth).Add(ns);
ns=ns.Inner;
}
}
return result.AsReadOnlyDictionary();
}