public void GenerationalDictionary2() { GenerationalDictionary <string, string> gd = new GenerationalDictionary <string, string>(); gd["one"] = "g0-one"; gd["two"] = "g0-two"; gd.NextGeneration(); gd["two"] = "g1-two"; gd.NextGeneration(); gd["one"] = "g2-one"; gd.NextGeneration(); gd["three"] = "g3-three"; var onekey = gd.GetHistoryOfKey("one"); Check.That(onekey.Count).Equals(2); var twokey = gd.GetHistoryOfKey("two"); Check.That(twokey.Count).Equals(2); var oneg2 = gd.GetHistoryOfKey(2, "one"); Check.That(oneg2.Count).Equals(2); var oneg1 = gd.GetHistoryOfKey(1, "one"); Check.That(oneg1.Count).Equals(1); var threeg1 = gd.GetHistoryOfKey(1, "three"); Check.That(threeg1.Count).Equals(0); var threeg10 = gd.GetHistoryOfKey(10, "three"); Check.That(threeg10.Count).Equals(1); }
/// <summary> /// Initializes a new instance of the <see cref="Condensation"/> class. /// </summary> /// <param name="automaton">The automaton.</param> /// <param name="root">The root of the condensation DAG.</param> /// <param name="transitionFilter"> /// A function specifying whether the transition should be treated as an edge /// of the automaton graph while building the condensation. /// </param> /// <param name="useApproximateClosure"> /// Specifies whether <see cref="Weight.ApproximateClosure"/> should be used /// instead of <see cref="Weight.Closure"/> in semiring computations. /// </param> internal Condensation( Automaton <TSequence, TElement, TElementDistribution, TSequenceManipulator, TThis> automaton, State root, Func <Transition, bool> transitionFilter, bool useApproximateClosure) { Debug.Assert(transitionFilter != null, "A valid transition filter must be provided."); this.automaton = automaton; this.Root = root; this.transitionFilter = transitionFilter; this.useApproximateClosure = useApproximateClosure; this.components = this.FindStronglyConnectedComponents(); this.stateInfo = PreallocatedAutomataObjects.LeaseComputeCondensationState(); for (int i = 0; i < this.components.Count; ++i) { StronglyConnectedComponent component = this.components[i]; for (int j = 0; j < component.Size; ++j) { this.stateInfo.Add(component.GetStateByIndex(j).Index, CondensationStateInfo.Default); } } }
public void GenerationalDictionary() { GenerationalDictionary <int, uint> gd = new GenerationalDictionary <int, uint>(); Random rnd = new Random(1001); const int generations = 1004; const int depth = 10000; const int modulo = 2; int[] genskip = new int[depth]; for (int i = 0; i < depth; i++) { genskip[i] = rnd.Next(23) + modulo + 1; // need to be bigger than modulo } for (uint g = 0; g < generations; g++) { gd.NextGeneration(); for (int i = 0; i < depth; i++) { if (g % genskip[i] == modulo) { // System.Diagnostics.Debug.WriteLine("{0} Add {1}", (g+1), i); gd[i] = g; } } } Stopwatch sw = new Stopwatch(); sw.Start(); long time = sw.ElapsedMilliseconds; //File.WriteAllText(@"c:\code\time.txt", "Time taken " + time); for (uint g = 0; g < generations; g++) { var dict = gd.Get(g + 1); // System.Diagnostics.Debug.WriteLine("At gen {0} get {1} {2}", g + 1, dict.Count, string.Join(",",dict.Values)); for (int i = 0; i < depth; i++) { bool present = g % genskip[i] == modulo; if (present) { Check.That(dict[i]).Equals(g); } else if (g < modulo) { Check.That(dict.ContainsKey(i)).IsFalse(); } else { Check.That(dict[i]).IsNotEqualTo(g); } } //foreach( var kvp in dict) { System.Diagnostics.Debug.WriteLine("{0} {1}={2}", g+1, kvp.Key, kvp.Value); } //System.Diagnostics.Debug.WriteLine(""); } for (uint g = 0; g < generations; g++) { var values = gd.GetValues(g + 1); for (int i = 0; i < depth; i++) { bool present = g % genskip[i] == modulo; if (present) { Check.That(values[i]).Equals(g); } else if (g < modulo) { Check.That(values.Contains((uint)i)).IsFalse(); } else { Check.That(values[i]).IsNotEqualTo(g); } } //foreach( var kvp in dict) { System.Diagnostics.Debug.WriteLine("{0} {1}={2}", g+1, kvp.Key, kvp.Value); } //System.Diagnostics.Debug.WriteLine(""); } //1004x10000 = release 3035 }
public MissionListAccumulator() { history = new GenerationalDictionary <string, MissionState>(); }
public Stats(Stats other) { history = other.history; }
public Stats() { history = new GenerationalDictionary <string, FactionInfo>(); }