public Enumerator(QuestCollectionIndexer collection) { this.collection = collection.arrayCollection; this.size = collection.dictCollection.Count; this.endIndex = collection.arrayCollection.Length; this.index = -1; this.count = 0; }
static void RunIteratorPartial() { var dictCollection = new QuestCollectionDictionary(MAX_SIZE); var indexCollection = new QuestCollectionIndexer(MAX_SIZE); var arrayCollection = new QuestCollectionArray(MAX_SIZE); var linkCollection = new QuestCollectionLink(MAX_SIZE); for (short i = 1; i <= MAX_SIZE; i++) { dictCollection.Add(i, new QuestProgression()); indexCollection.Add(i, new QuestProgression()); arrayCollection.Add(i, new QuestProgression()); linkCollection.Add(i, new QuestProgression()); } var sw1 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { foreach (var entry in dictCollection) { var questId = entry.Key; var progression = entry.Value; } } sw1.Stop(); Console.WriteLine("QuestCollectionDictionary " + sw1.ElapsedMilliseconds); var sw2 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { foreach (var entry in indexCollection) { var questId = entry.Key; var progression = entry.Value; } } sw2.Stop(); Console.WriteLine("QuestCollectionIndexer " + sw2.ElapsedMilliseconds); var sw3 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { foreach (var entry in arrayCollection) { var questId = entry.Key; var progression = entry.Value; } } sw3.Stop(); Console.WriteLine("QuestCollectionArray " + sw3.ElapsedMilliseconds); var sw7 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { foreach (var entry in linkCollection) { var questId = entry.Key; var progression = entry.Value; } } sw7.Stop(); Console.WriteLine("QuestCollectionLink " + sw7.ElapsedMilliseconds); var sw4 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { foreach (var entry in arrayCollection) { var questId = entry.Key; var progression = entry.Value; } } sw4.Stop(); Console.WriteLine("QuestCollectionArray " + sw4.ElapsedMilliseconds); var sw5 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { foreach (var entry in indexCollection) { var questId = entry.Key; var progression = entry.Value; } } sw5.Stop(); Console.WriteLine("QuestCollectionIndexer " + sw5.ElapsedMilliseconds); var sw6 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { foreach (var entry in dictCollection) { var questId = entry.Key; var progression = entry.Value; } } sw6.Stop(); Console.WriteLine("QuestCollectionDictionary " + sw6.ElapsedMilliseconds); var sw8 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { foreach (var entry in linkCollection) { var questId = entry.Key; var progression = entry.Value; } } sw8.Stop(); Console.WriteLine("QuestCollectionLink " + sw8.ElapsedMilliseconds); }
static void RunLocatorFilled() { var dictCollection = new QuestCollectionDictionary(MAX_SIZE); var indexCollection = new QuestCollectionIndexer(MAX_SIZE); var arrayCollection = new QuestCollectionArray(MAX_SIZE); var linkCollection = new QuestCollectionLink(MAX_SIZE); for (short i = 1; i <= MAX_SIZE; i++) { dictCollection.Add(i, new QuestProgression()); indexCollection.Add(i, new QuestProgression()); arrayCollection.Add(i, new QuestProgression()); linkCollection.Add(i, new QuestProgression()); } var sw1 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { for (short j = 1; j <= MAX_SIZE; j++) { QuestProgression progression; dictCollection.TryGetValue(j, out progression); } } sw1.Stop(); Console.WriteLine("QuestCollectionDictionary " + sw1.ElapsedMilliseconds); var sw2 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { for (short j = 1; j <= MAX_SIZE; j++) { QuestProgression progression; indexCollection.TryGetValue(j, out progression); } } sw2.Stop(); Console.WriteLine("QuestCollectionIndexer " + sw2.ElapsedMilliseconds); var sw3 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { for (short j = 1; j <= MAX_SIZE; j++) { QuestProgression progression; arrayCollection.TryGetValue(j, out progression); } } sw3.Stop(); Console.WriteLine("QuestCollectionArray " + sw3.ElapsedMilliseconds); var sw7 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { for (short j = 1; j <= MAX_SIZE; j++) { QuestProgression progression; linkCollection.TryGetValue(j, out progression); } } sw7.Stop(); Console.WriteLine("QuestCollectionLink " + sw7.ElapsedMilliseconds); var sw4 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { for (short j = 1; j <= MAX_SIZE; j++) { QuestProgression progression; arrayCollection.TryGetValue(j, out progression); } } sw4.Stop(); Console.WriteLine("QuestCollectionArray " + sw4.ElapsedMilliseconds); var sw5 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { for (short j = 1; j <= MAX_SIZE; j++) { QuestProgression progression; indexCollection.TryGetValue(j, out progression); } } sw5.Stop(); Console.WriteLine("QuestCollectionIndexer " + sw5.ElapsedMilliseconds); var sw6 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { for (short j = 1; j <= MAX_SIZE; j++) { QuestProgression progression; dictCollection.TryGetValue(j, out progression); } } sw6.Stop(); Console.WriteLine("QuestCollectionDictionary " + sw6.ElapsedMilliseconds); var sw8 = Stopwatch.StartNew(); for (var i = 0; i < ITERATION; i++) { for (short j = 1; j <= MAX_SIZE; j++) { QuestProgression progression; linkCollection.TryGetValue(j, out progression); } } sw8.Stop(); Console.WriteLine("QuestCollectionLink " + sw8.ElapsedMilliseconds); }