本文整理汇总了C#中Map.get方法的典型用法代码示例。如果您正苦于以下问题:C# Map.get方法的具体用法?C# Map.get怎么用?C# Map.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkIsDAGAndCollectVariablesInTopologicalOrder
// END-BayesianNetwork
//
//
// PRIVATE METHODS
//
private void checkIsDAGAndCollectVariablesInTopologicalOrder()
{
// Topological sort based on logic described at:
// http://en.wikipedia.org/wiki/Topoligical_sorting
Set<Node> seenAlready = new Set<Node>();
Map<Node, List<Node>> incomingEdges = new Map<Node, List<Node>>();
Set<Node> s = new Set<Node>();
foreach (Node n in this.rootNodes)
{
walkNode(n, seenAlready, incomingEdges, s);
}
while (!(s.Count == 0))
{
HashSet<Node>.Enumerator enumerator = s.GetEnumerator();
enumerator.MoveNext();
Node n = enumerator.Current;
s.remove(n);
variables.Add(n.getRandomVariable());
varToNodeMap.put(n.getRandomVariable(), n);
foreach (Node m in n.getChildren())
{
List<Node> edges = incomingEdges.get(m);
edges.Remove(n);
if (edges.Count == 0)
{
s.add(m);
}
}
}
foreach (List<Node> edges in incomingEdges.values())
{
if (!(edges.Count == 0))
{
throw new IllegalArgumentException(
"Network contains at least one cycle in it, must be a DAG.");
}
}
}
示例2: initEntries
internal void initEntries(Map<String, Attributes> entries,
Map<String, Chunk> chunks)
{
//throws IOException {
int mark = pos;
while (readHeader())
{
if (!AttributesNS.Name.NAME.equals(name))
{
throw new java.io.IOException("Entry is not named"); //$NON-NLS-1$
}
String entryNameValue = value;
Attributes entry = entries.get(entryNameValue);
if (entry == null)
{
entry = new Attributes(12);
}
while (readHeader())
{
entry.put(name, value);
}
if (chunks != null)
{
if (chunks.get(entryNameValue) != null)
{
// TODO A bug: there might be several verification chunks for
// the same name. I believe they should be used to update
// signature in order of appearance; there are two ways to fix
// this: either use a list of chunks, or decide on used
// signature algorithm in advance and reread the chunks while
// updating the signature; for now a defensive error is thrown
throw new java.io.IOException("A jar verifier does not support more than one entry with the same name"); //$NON-NLS-1$
}
chunks.put(entryNameValue, new Chunk(mark, pos));
mark = pos;
}
entries.put(entryNameValue, entry);
}
}
示例3: indexesOfValue
/**
* Calculate the indexes for X[i] into a vector representing the enumeration
* of the value assignments for the variables X and their corresponding
* assignment in x. For example the Random Variables:<br>
* Q::{true, false}, R::{'A', 'B','C'}, and T::{true, false}, would be
* enumerated in a Vector as follows:
*
* <pre>
* Index Q R T
* ----- - - -
* 00: true, A, true
* 01: true, A, false
* 02: true, B, true
* 03: true, B, false
* 04: true, C, true
* 05: true, C, false
* 06: false, A, true
* 07: false, A, false
* 08: false, B, true
* 09: false, B, false
* 10: false, C, true
* 11: false, C, false
* </pre>
*
* if X[i] = R and x = {..., R='C', ...} then the indexes returned would be
* [4, 5, 10, 11].
*
* @param X
* a list of the Random Variables that would comprise the vector.
* @param idx
* the index into X for the Random Variable whose assignment we
* wish to retrieve its indexes for.
* @param x
* an assignment for the Random Variables in X.
* @return the indexes into a vector that would represent the enumeration of
* the values for X[i] in x.
*/
public static int[] indexesOfValue(RandomVariable[] X, int idx,
Map<RandomVariable, Object> x)
{
int csize = ProbUtil.expectedSizeOfCategoricalDistribution(X);
FiniteDomain fd = (FiniteDomain) X[idx].getDomain();
int vdoffset = fd.getOffset(x.get(X[idx]));
int vdosize = fd.size();
int[] indexes = new int[csize/vdosize];
int blocksize = csize;
for (int i = 0; i < X.length; i++)
{
blocksize = blocksize/X[i].getDomain().size();
if (i == idx)
{
break;
}
}
for (int i = 0; i < indexes.Length; i += blocksize)
{
int offset = ((i/blocksize)*vdosize*blocksize)
+ (blocksize*vdoffset);
for (int b = 0; b < blocksize; b++)
{
indexes[i + b] = offset + b;
}
}
return indexes;
}
示例4: indexOf
/**
* Calculate the index into a vector representing the enumeration of the
* value assignments for the variables X and their corresponding assignment
* in x. For example the Random Variables:<br>
* Q::{true, false}, R::{'A', 'B','C'}, and T::{true, false}, would be
* enumerated in a Vector as follows:
*
* <pre>
* Index Q R T
* ----- - - -
* 00: true, A, true
* 01: true, A, false
* 02: true, B, true
* 03: true, B, false
* 04: true, C, true
* 05: true, C, false
* 06: false, A, true
* 07: false, A, false
* 08: false, B, true
* 09: false, B, false
* 10: false, C, true
* 11: false, C, false
* </pre>
*
* if x = {Q=true, R='C', T=false} the index returned would be 5.
*
* @param X
* a list of the Random Variables that would comprise the vector.
* @param x
* an assignment for the Random Variables in X.
* @return an index into a vector that would represent the enumeration of
* the values for X.
*/
public static int indexOf(RandomVariable[] X, Map<RandomVariable, Object> x)
{
if (0 == X.length)
{
return ((FiniteDomain) X[0].getDomain()).getOffset(x.get(X[0]));
}
// X.length > 1 then calculate using a mixed radix number
//
// Note: Create radices in reverse order so that the enumeration
// through the distributions is of the following
// order using a MixedRadixNumber, e.g. for two Booleans:
// X Y
// true true
// true false
// false true
// false false
// which corresponds with how displayed in book.
int[] radixValues = new int[X.length];
int[] radices = new int[X.length];
int j = X.length - 1;
for (int i = 0; i < X.length; i++)
{
FiniteDomain fd = (FiniteDomain) X[i].getDomain();
radixValues[j] = fd.getOffset(x.get(X[i]));
radices[j] = fd.size();
j--;
}
return new MixedRadixNumber(radixValues, radices).intValue();
}
示例5: getEventValuesForXiGivenParents
/**
* Get the values for the Random Variable Xi's parents and its own value
* from the provided event.
*
* @param Xi
* a Node for the Random Variable Xi whose parent values are to
* be extracted from the provided event in the correct order.
* @param xDelta
* the value for the Random Variable Xi to be assigned to the
* values returned.
* @param event
* an event containing assignments for Xi's parents and its own
* value.
* @return an ordered set of values for the parents of Xi and its value from
* the provided event.
*/
public static Object[] getEventValuesForXiGivenParents(Node Xi,
Object xDelta, Map<RandomVariable, Object> evt)
{
Object[] values = new Object[Xi.getParents().Count + 1];
int idx = 0;
foreach (Node pn in Xi.getParents())
{
values[idx] = evt.get(pn.getRandomVariable());
idx++;
}
values[idx] = xDelta;
return values;
}
示例6: isConsistent
// END-BayesSampleInference
//
//
// PRIVATE METHODS
//
private bool isConsistent(Map<RandomVariable, Object> x,
AssignmentProposition[] e)
{
foreach (AssignmentProposition ap in e)
{
if (!ap.getValue().Equals(x.get(ap.getTermVariable())))
{
return false;
}
}
return true;
}
示例7: copyTo
public virtual File copyTo(File to, Map options)
{
// sanity
if (isDir() != to.isDir())
{
if (isDir())
throw ArgErr.make("copyTo must be dir `" + to + "`").val;
else
throw ArgErr.make("copyTo must not be dir `" + to + "`").val;
}
// options
object exclude = null, overwrite = null;
if (options != null)
{
exclude = options.get(optExclude);
overwrite = options.get(optOverwrite);
}
// recurse
doCopyTo(to, exclude, overwrite);
return to;
}