// this is a no-allocation way to sum an int queue internal static int Sum(System.Collections.Generic.Queue<int> queue) { var value = 0; for (int i = 0; i < queue.Count; i++) { var temp = queue.Dequeue(); value += temp; queue.Enqueue(temp); } return value; }
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case ".": s = new itemSet_251(this, tok, count); wl.Enqueue(s); break; case "[": s = new itemSet_246(this, tok, count); wl.Enqueue(s); break; case "--": s = new itemSet_247(this, tok, count); wl.Enqueue(s); break; case "(": s = new itemSet_248(this, tok, count); wl.Enqueue(s); break; case "++": s = new itemSet_249(this, tok, count); wl.Enqueue(s); break; case "->": s = new itemSet_250(this, tok, count); wl.Enqueue(s); break; case "+": case ";": case "%=": case "-=": case "==": case ">>=": case "&=": case ">=": case "^=": case "%": case "-": case "=": case "]": case "}": case "/=": case "<<": case "as": case "is": case "||": case "*": case ":": case "/": case "?": case "!=": case "<<=": case ",": case "<": case "|": case "*=": case ")": case "&&": case "+=": case ">>": case "&": case ">": case "^": case "<=": case "|=": if (true ) { s = this.below.shiftNonterm("unary-expression", count, tok.coord, "unary-expression : primary-expression", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "byte": s = new itemSet_96(this, tok, count); wl.Enqueue(s); break; case "uint": s = new itemSet_97(this, tok, count); wl.Enqueue(s); break; case "delegate": s = new itemSet_79(this, tok, count); wl.Enqueue(s); break; case "enum": s = new itemSet_80(this, tok, count); wl.Enqueue(s); break; case "interface": s = new itemSet_81(this, tok, count); wl.Enqueue(s); break; case "struct": s = new itemSet_82(this, tok, count); wl.Enqueue(s); break; case "class": s = new itemSet_83(this, tok, count); wl.Enqueue(s); break; case "const": s = new itemSet_518(this, tok, count); wl.Enqueue(s); break; case "sbyte": s = new itemSet_100(this, tok, count); wl.Enqueue(s); break; case "double": s = new itemSet_101(this, tok, count); wl.Enqueue(s); break; case "object": s = new itemSet_102(this, tok, count); wl.Enqueue(s); break; case "int": s = new itemSet_103(this, tok, count); wl.Enqueue(s); break; case "char": s = new itemSet_104(this, tok, count); wl.Enqueue(s); break; case "void": s = new itemSet_105(this, tok, count); wl.Enqueue(s); break; case "implicit": s = new itemSet_520(this, tok, count); wl.Enqueue(s); break; case "ushort": s = new itemSet_107(this, tok, count); wl.Enqueue(s); break; case "bool": s = new itemSet_108(this, tok, count); wl.Enqueue(s); break; case "long": s = new itemSet_109(this, tok, count); wl.Enqueue(s); break; case "identifier": s = new itemSet_523(this, tok, count); wl.Enqueue(s); break; case "string": s = new itemSet_111(this, tok, count); wl.Enqueue(s); break; case "short": s = new itemSet_113(this, tok, count); wl.Enqueue(s); break; case "explicit": s = new itemSet_514(this, tok, count); wl.Enqueue(s); break; case "decimal": s = new itemSet_115(this, tok, count); wl.Enqueue(s); break; case "ulong": s = new itemSet_116(this, tok, count); wl.Enqueue(s); break; case "~": s = new itemSet_588(this, tok, count); wl.Enqueue(s); break; case "event": s = new itemSet_515(this, tok, count); wl.Enqueue(s); break; case "float": s = new itemSet_118(this, tok, count); wl.Enqueue(s); break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "volatile": s = new itemSet_51(this, tok, count); wl.Enqueue(s); break; case "abstract": s = new itemSet_52(this, tok, count); wl.Enqueue(s); break; case "override": s = new itemSet_53(this, tok, count); wl.Enqueue(s); break; case "internal": s = new itemSet_56(this, tok, count); wl.Enqueue(s); break; case "protected": s = new itemSet_59(this, tok, count); wl.Enqueue(s); break; case "private": s = new itemSet_63(this, tok, count); wl.Enqueue(s); break; case "readonly": s = new itemSet_64(this, tok, count); wl.Enqueue(s); break; case "extern": s = new itemSet_49(this, tok, count); wl.Enqueue(s); break; case "sealed": s = new itemSet_50(this, tok, count); wl.Enqueue(s); break; case "unsafe": s = new itemSet_54(this, tok, count); wl.Enqueue(s); break; case "new": s = new itemSet_55(this, tok, count); wl.Enqueue(s); break; case "static": s = new itemSet_57(this, tok, count); wl.Enqueue(s); break; case "virtual": s = new itemSet_58(this, tok, count); wl.Enqueue(s); break; case "public": s = new itemSet_62(this, tok, count); wl.Enqueue(s); break; case "byte": case "uint": case "const": case "sbyte": case "double": case "object": case "int": case "char": case "void": case "implicit": case "ushort": case "delegate": case "bool": case "long": case "enum": case "identifier": case "string": case "short": case "explicit": case "decimal": case "interface": case "ulong": case "~": case "struct": case "class": case "event": case "float": if (true ) { s = this.shiftNonterm("member-modifiersopt", count, tok.coord, "member-modifiersopt :", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "{": if (true ) { s = this.shiftNonterm("class-baseopt", count, tok.coord, "class-baseopt :", this); if (s != null) { s.transitions(wl, tok, count); } } break; case ":": s = new itemSet_230(this, tok, count); wl.Enqueue(s); break; } // switch } // transitions
public async Task<Errorable<TreeNode>> PersistTree(TreeID rootid, ImmutableContainer<TreeID, TreeNode> trees) { if (trees == null) throw new ArgumentNullException("trees"); // TODO: better return value than `null` if (trees.Count == 0) return (TreeNode)null; // Start a query to check what Trees exist already: var existTrees = await db.ExecuteListQueryAsync(new QueryTreesExist(trees.Keys), expectedCapacity: trees.Count); // This code scans the tree breadth-first and builds a reversed depth-ordered stack: var reverseDepthOrder = new { id = rootid, depth = 0 }.StackOf(trees.Count); reverseDepthOrder.Pop(); var breadthFirstQueue = new { id = rootid, depth = 0 }.QueueOf(trees.Count); while (breadthFirstQueue.Count > 0) { var curr = breadthFirstQueue.Dequeue(); // Add it to the reverse stack: reverseDepthOrder.Push(curr); TreeNode node; if (!trees.TryGetValue(curr.id, out node)) { // TODO: didn't find the TreeID in the given collection, assume already persisted? continue; } // Queue up the child TreeIDs: foreach (var trtr in node.Trees) breadthFirstQueue.Enqueue(new { id = trtr.TreeID, depth = curr.depth + 1 }); } // This code takes the reverse depth-ordered stack and persists the tree nodes in groups per depth level. // This ensures that all child nodes across the breadth of the tree at each depth level are persisted // before moving up to their parents. List<Task<Errorable<TreeNode>>> persistTasks = new List<Task<Errorable<TreeNode>>>(); // Initialize the `isPersisting` set with the set of TreeIDs that already exist. HashSet<TreeID> isPersisting = new HashSet<TreeID>(existTrees); int lastDepth = reverseDepthOrder.Peek().depth; foreach (var curr in reverseDepthOrder) { Debug.WriteLine(String.Format("{0}: {1}", curr.depth, curr.id.ToString(firstLength: 7))); // An invariant of the algorithm, enforced via assert: Debug.Assert(curr.depth <= lastDepth); // Did we move to the next depth group: if ((persistTasks.Count > 0) && (curr.depth != lastDepth)) { Debug.WriteLine(String.Format("Awaiting depth group {0}...", lastDepth)); // Wait for the last depth group to finish persisting: await Task.WhenAll(persistTasks); // Start a new depth group: persistTasks = new List<Task<Errorable<TreeNode>>>(); } // Don't re-persist the same TreeID (this is a legit case - the same TreeID may be seen in different nodes of the tree): if (isPersisting.Contains(curr.id)) { Debug.WriteLine(String.Format("Already persisting {0}", curr.id.ToString(firstLength: 7))); // Keep track of the last depth level: lastDepth = curr.depth; continue; } // Get the TreeNode and persist it: TreeNode node = trees[curr.id]; isPersisting.Add(curr.id); // Fire up a task to persist this tree node: var tsk = db.ExecuteNonQueryAsync(new PersistTree(node)); // Add the task to the depth group to await: Debug.WriteLine(String.Format("Adding to depth group {0}...", curr.depth)); persistTasks.Add(tsk); // Keep track of the last depth level: lastDepth = curr.depth; } Debug.Assert(lastDepth == 0); if (persistTasks.Count > 0) { // Await the last group (the root node): Debug.WriteLine(String.Format("Awaiting depth group {0}...", lastDepth)); await Task.WhenAll(persistTasks); } // Return the root TreeNode: return trees[rootid]; }
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "+": s = new itemSet_190(this, tok, count); wl.Enqueue(s); break; case "--": s = new itemSet_146(this, tok, count); wl.Enqueue(s); break; case "byte": s = new itemSet_148(this, tok, count); wl.Enqueue(s); break; case "this": s = new itemSet_130(this, tok, count); wl.Enqueue(s); break; case "true": s = new itemSet_149(this, tok, count); wl.Enqueue(s); break; case "uint": s = new itemSet_170(this, tok, count); wl.Enqueue(s); break; case "sbyte": s = new itemSet_194(this, tok, count); wl.Enqueue(s); break; case "(": s = new itemSet_150(this, tok, count); wl.Enqueue(s); break; case "new": s = new itemSet_151(this, tok, count); wl.Enqueue(s); break; case "double": s = new itemSet_152(this, tok, count); wl.Enqueue(s); break; case "real-literal": s = new itemSet_153(this, tok, count); wl.Enqueue(s); break; case "object": s = new itemSet_133(this, tok, count); wl.Enqueue(s); break; case "-": s = new itemSet_134(this, tok, count); wl.Enqueue(s); break; case "int": s = new itemSet_154(this, tok, count); wl.Enqueue(s); break; case "checked": s = new itemSet_135(this, tok, count); wl.Enqueue(s); break; case "char": s = new itemSet_172(this, tok, count); wl.Enqueue(s); break; case "*": s = new itemSet_175(this, tok, count); wl.Enqueue(s); break; case "string-literal": s = new itemSet_137(this, tok, count); wl.Enqueue(s); break; case "null": s = new itemSet_200(this, tok, count); wl.Enqueue(s); break; case "unchecked": s = new itemSet_201(this, tok, count); wl.Enqueue(s); break; case "ushort": s = new itemSet_176(this, tok, count); wl.Enqueue(s); break; case "++": s = new itemSet_155(this, tok, count); wl.Enqueue(s); break; case "bool": s = new itemSet_156(this, tok, count); wl.Enqueue(s); break; case "long": s = new itemSet_140(this, tok, count); wl.Enqueue(s); break; case "false": s = new itemSet_141(this, tok, count); wl.Enqueue(s); break; case "typeof": s = new itemSet_206(this, tok, count); wl.Enqueue(s); break; case "identifier": s = new itemSet_234(this, tok, count); wl.Enqueue(s); break; case "string": s = new itemSet_162(this, tok, count); wl.Enqueue(s); break; case "short": s = new itemSet_180(this, tok, count); wl.Enqueue(s); break; case "!": s = new itemSet_142(this, tok, count); wl.Enqueue(s); break; case "decimal": s = new itemSet_163(this, tok, count); wl.Enqueue(s); break; case "sizeof": s = new itemSet_164(this, tok, count); wl.Enqueue(s); break; case "ulong": s = new itemSet_210(this, tok, count); wl.Enqueue(s); break; case "&": s = new itemSet_211(this, tok, count); wl.Enqueue(s); break; case "~": s = new itemSet_183(this, tok, count); wl.Enqueue(s); break; case "base": s = new itemSet_184(this, tok, count); wl.Enqueue(s); break; case "integer-literal": s = new itemSet_186(this, tok, count); wl.Enqueue(s); break; case "float": s = new itemSet_212(this, tok, count); wl.Enqueue(s); break; case "character-literal": s = new itemSet_213(this, tok, count); wl.Enqueue(s); break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "(": s = new itemSet_235(this, tok, count); wl.Enqueue(s); break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "new": s = new itemSet_478(this, tok, count); wl.Enqueue(s); break; case "byte": case "uint": case "sbyte": case "double": case "object": case "int": case "char": case "void": case "ushort": case "bool": case "long": case "identifier": case "string": case "short": case "decimal": case "ulong": case "event": case "float": if (true ) { s = this.shiftNonterm("newopt", count, tok.coord, "newopt :", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "%": s = new itemSet_297(this, tok, count); wl.Enqueue(s); break; case "*": s = new itemSet_298(this, tok, count); wl.Enqueue(s); break; case "/": s = new itemSet_299(this, tok, count); wl.Enqueue(s); break; case "+": case ";": case "==": case ">=": case "-": case "]": case "}": case "<<": case "as": case "is": case "||": case ":": case "?": case "!=": case ",": case "<": case "|": case ")": case "&&": case ">>": case "&": case ">": case "^": case "<=": if (true ) { s = this.below.below.below.shiftNonterm("additive-expression", count, tok.coord, "additive-expression : additive-expression - multiplicative-expression", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "catch": s = new itemSet_721(this, tok, count); wl.Enqueue(s); if (true ) { s = this.below.shiftNonterm("specific-catch-clausesopt", count, tok.coord, "specific-catch-clausesopt : specific-catch-clauses", this); if (s != null) { s.transitions(wl, tok, count); } } break; case "this": case "uint": case "do": case "if": case "object": case "-": case "}": case "for": case "checked": case "char": case "void": case "finally": case "break": case "*": case "string-literal": case "ushort": case "long": case "switch": case "false": case "lock": case "continue": case "fixed": case "short": case "throw": case "!": case "try": case "~": case "base": case "integer-literal": case "using": case "+": case ";": case "{": case "--": case "byte": case "case": case "true": case "default": case "const": case "sbyte": case "(": case "new": case "else": case "double": case "real-literal": case "int": case "typeswitch": case "while": case "null": case "unchecked": case "foreach": case "++": case "bool": case "goto": case "typeof": case "identifier": case "string": case "decimal": case "sizeof": case "return": case "ulong": case "&": case "float": case "character-literal": if (true ) { s = this.below.shiftNonterm("catch-clauses", count, tok.coord, "catch-clauses : specific-catch-clauses", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case ",": s = new itemSet_495(this, tok, count); wl.Enqueue(s); break; case "}": if (true ) { s = this.below.shiftNonterm("variable-initializer-listopt", count, tok.coord, "variable-initializer-listopt : variable-initializer-list", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case ",": s = new itemSet_473(this, tok, count); wl.Enqueue(s); break; case "]": case ")": if (true ) { s = this.below.shiftNonterm("formal-parameter-list", count, tok.coord, "formal-parameter-list : fixed-parameters", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "||": s = new itemSet_285(this, tok, count); wl.Enqueue(s); break; case "?": s = new itemSet_286(this, tok, count); wl.Enqueue(s); break; case ";": case "]": case "}": case ":": case ",": case ")": if (true ) { s = this.below.shiftNonterm("conditional-expression", count, tok.coord, "conditional-expression : conditional-or-expression", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "byte": s = new itemSet_96(this, tok, count); wl.Enqueue(s); break; case "uint": s = new itemSet_97(this, tok, count); wl.Enqueue(s); break; case "sbyte": s = new itemSet_100(this, tok, count); wl.Enqueue(s); break; case "int": s = new itemSet_103(this, tok, count); wl.Enqueue(s); break; case "char": s = new itemSet_104(this, tok, count); wl.Enqueue(s); break; case "ushort": s = new itemSet_107(this, tok, count); wl.Enqueue(s); break; case "long": s = new itemSet_109(this, tok, count); wl.Enqueue(s); break; case "short": s = new itemSet_113(this, tok, count); wl.Enqueue(s); break; case "ulong": s = new itemSet_116(this, tok, count); wl.Enqueue(s); break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case ">=": s = new itemSet_236(this, tok, count); wl.Enqueue(s); break; case "as": s = new itemSet_237(this, tok, count); wl.Enqueue(s); break; case "is": s = new itemSet_238(this, tok, count); wl.Enqueue(s); break; case "<": s = new itemSet_239(this, tok, count); wl.Enqueue(s); break; case ">": s = new itemSet_240(this, tok, count); wl.Enqueue(s); break; case "<=": s = new itemSet_241(this, tok, count); wl.Enqueue(s); break; case ";": case "==": case "]": case "}": case "||": case ":": case "?": case "!=": case ",": case "|": case ")": case "&&": case "&": case "^": if (true ) { s = this.below.below.below.shiftNonterm("equality-expression", count, tok.coord, "equality-expression : equality-expression != relational-expression", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "{": case "this": case "operator": case "identifier": if (true ) { s = this.below.shiftNonterm("namespace-or-type-name", count, tok.coord, "namespace-or-type-name : identifier", this); if (s != null) { s.transitions(wl, tok, count); } } break; case "+": case "%=": case "--": case "-=": case ">>=": case "&=": case "^=": case "%": case "-": case "=": case "/=": case "<<": case "/": case "++": case "<<=": case "*=": case "->": case "+=": case ">>": case "|=": if (true ) { s = this.below.shiftNonterm("simple-name", count, tok.coord, "simple-name : identifier", this); if (s != null) { s.transitions(wl, tok, count); } } break; case ":": s = new itemSet_642(this, tok, count); wl.Enqueue(s); if (true ) { s = this.below.shiftNonterm("namespace-or-type-name", count, tok.coord, "namespace-or-type-name : identifier", this); if (s != null) { s.transitions(wl, tok, count); } } if (true ) { s = this.below.shiftNonterm("simple-name", count, tok.coord, "simple-name : identifier", this); if (s != null) { s.transitions(wl, tok, count); } } break; case ";": case "[": case "==": case "(": case ">=": case "]": case "}": case "as": case "is": case "||": case "*": case "?": case "!=": case ",": case "<": case "|": case ")": case "&&": case "&": case ".": case ">": case "^": case "<=": if (true ) { s = this.below.shiftNonterm("namespace-or-type-name", count, tok.coord, "namespace-or-type-name : identifier", this); if (s != null) { s.transitions(wl, tok, count); } } if (true ) { s = this.below.shiftNonterm("simple-name", count, tok.coord, "simple-name : identifier", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "identifier": s = new itemSet_71(this, tok, count); wl.Enqueue(s); break; case "object": s = new itemSet_102(this, tok, count); wl.Enqueue(s); break; case "string": s = new itemSet_111(this, tok, count); wl.Enqueue(s); break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "[": s = new itemSet_218(this, tok, count); wl.Enqueue(s); if (true ) { s = this.below.shiftNonterm("unmanaged-type", count, tok.coord, "unmanaged-type : type", this); if (s != null) { s.transitions(wl, tok, count); } } break; case ")": s = new itemSet_343(this, tok, count); wl.Enqueue(s); if (true ) { s = this.below.shiftNonterm("unmanaged-type", count, tok.coord, "unmanaged-type : type", this); if (s != null) { s.transitions(wl, tok, count); } } break; case "*": if (true ) { s = this.below.shiftNonterm("unmanaged-type", count, tok.coord, "unmanaged-type : type", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { if (tok.tag == "<EOF>") { wl.Enqueue(this); } }
public override object CalculateResult() { return new Range(NumGames) .AsParallel() .Select(x => { Random random = MathUtilities.CreateRandom(); var communityChestCards = new[] { CommunityChestCard.AdvanceToGo, CommunityChestCard.GoToJail, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, CommunityChestCard.Other, } .Shuffle(random) .ToQueue(); var chanceCards = new[] { ChanceCard.AdvanceToGo, ChanceCard.GoToJail, ChanceCard.GoToC1, ChanceCard.GoToE3, ChanceCard.GoToH2, ChanceCard.GoToRailroad1, ChanceCard.GoToNextRailroad, ChanceCard.GoToNextRailroad, ChanceCard.GoToNextUtility, ChanceCard.GoBackThreeSquares, ChanceCard.Other, ChanceCard.Other, ChanceCard.Other, ChanceCard.Other, ChanceCard.Other, ChanceCard.Other, } .Shuffle(random) .ToQueue(); Square currentPosition = Square.Go; Action refixPosition = () => { while (currentPosition < Square.Go) { currentPosition += BoardSize; } while (currentPosition > Square.H2) { currentPosition -= BoardSize; } }; DefaultDictionary<Square, int> landings = new DefaultDictionary<Square, int>(s => 0); for (int i = 0; i < NumTurnsPerGame; i++) { int numDoubles = 0; int die1 = random.Next(1, 1 + DieSize); int die2 = random.Next(1, 1 + DieSize); if (die1 == die2) { numDoubles++; } else { numDoubles = 0; } if (numDoubles == 3) { numDoubles = 0; currentPosition = Square.Jail; } else { currentPosition += die1 + die2; refixPosition(); checkPosition: if (currentPosition == Square.GoToJail) { currentPosition = Square.Jail; } else if (Chances.Contains(currentPosition)) { ChanceCard card = chanceCards.Dequeue(); chanceCards.Enqueue(card); switch (card) { case ChanceCard.AdvanceToGo: currentPosition = Square.Go; break; case ChanceCard.GoToJail: currentPosition = Square.GoToJail; break; case ChanceCard.GoToC1: currentPosition = Square.C1; break; case ChanceCard.GoToE3: currentPosition = Square.E3; break; case ChanceCard.GoToH2: currentPosition = Square.H2; break; case ChanceCard.GoToRailroad1: currentPosition = Square.Railroad1; break; case ChanceCard.GoToNextRailroad: while (!Railroads.Contains(currentPosition)) { currentPosition++; refixPosition(); } break; case ChanceCard.GoToNextUtility: while (!Utilities.Contains(currentPosition)) { currentPosition++; refixPosition(); } break; case ChanceCard.GoBackThreeSquares: currentPosition -= 3; refixPosition(); goto checkPosition; // I hate gotos, but it's the cleanest way in this case. } } else if (CommunityChests.Contains(currentPosition)) { CommunityChestCard card = communityChestCards.Dequeue(); communityChestCards.Enqueue(card); switch (card) { case CommunityChestCard.AdvanceToGo: currentPosition = Square.Go; break; case CommunityChestCard.GoToJail: currentPosition = Square.Jail; break; } } } landings[currentPosition]++; } return landings; }) .Aggregate((a, b) => { foreach (var pair in b) { if (!a.ContainsKey(pair.Key)) { a[pair.Key] = 0; } a[pair.Key] += pair.Value; } return a; }) .OrderByDescending(p => p.Value) .Select(p => p.Key) .Take(3) .Select(s => ((int)s).ToString("00")) .StringJoin(string.Empty); }
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "delegate": s = new itemSet_79(this, tok, count); wl.Enqueue(s); break; case "enum": s = new itemSet_80(this, tok, count); wl.Enqueue(s); break; case "interface": s = new itemSet_81(this, tok, count); wl.Enqueue(s); break; case "struct": s = new itemSet_82(this, tok, count); wl.Enqueue(s); break; case "class": s = new itemSet_83(this, tok, count); wl.Enqueue(s); break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "byte": s = new itemSet_96(this, tok, count); wl.Enqueue(s); break; case "uint": s = new itemSet_97(this, tok, count); wl.Enqueue(s); break; case "identifier": s = new itemSet_71(this, tok, count); wl.Enqueue(s); break; case "sbyte": s = new itemSet_100(this, tok, count); wl.Enqueue(s); break; case "double": s = new itemSet_101(this, tok, count); wl.Enqueue(s); break; case "object": s = new itemSet_102(this, tok, count); wl.Enqueue(s); break; case "int": s = new itemSet_103(this, tok, count); wl.Enqueue(s); break; case "char": s = new itemSet_104(this, tok, count); wl.Enqueue(s); break; case "void": s = new itemSet_253(this, tok, count); wl.Enqueue(s); break; case "ushort": s = new itemSet_107(this, tok, count); wl.Enqueue(s); break; case "bool": s = new itemSet_108(this, tok, count); wl.Enqueue(s); break; case "long": s = new itemSet_109(this, tok, count); wl.Enqueue(s); break; case "string": s = new itemSet_111(this, tok, count); wl.Enqueue(s); break; case "short": s = new itemSet_113(this, tok, count); wl.Enqueue(s); break; case "decimal": s = new itemSet_115(this, tok, count); wl.Enqueue(s); break; case "ulong": s = new itemSet_116(this, tok, count); wl.Enqueue(s); break; case "float": s = new itemSet_118(this, tok, count); wl.Enqueue(s); break; } // switch } // transitions
public override void transitions(System.Collections.Queue wl, InputElement tok, int count) { state s; switch (tok.tag) { default: return; case "using": s = new itemSet_9(this, tok, count); wl.Enqueue(s); break; case "[": case "extern": case "sealed": case "volatile": case "abstract": case "override": case "unsafe": case "new": case "internal": case "}": case "static": case "virtual": case "protected": case "delegate": case "enum": case "public": case "<EOF>": case "private": case "interface": case "namespace": case "readonly": case "struct": case "class": if (true ) { s = this.shiftNonterm("using-directivesopt", count, tok.coord, "using-directivesopt :", this); if (s != null) { s.transitions(wl, tok, count); } } break; } // switch } // transitions