- Timestamp:
- 11/23/15 18:47:21 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/Index.cs
r13326 r13347 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 33 33 34 34 public Index() { 35 indexes = new Dictionary<T, uint>();36 values = new Dictionary<uint, T>();37 nextIndex = 1;35 this.indexes = new Dictionary<T, uint>(); 36 this.values = new Dictionary<uint, T>(); 37 nextIndex = 0; 38 38 } 39 public Index(IEnumerable<T uple<uint, T>> values)39 public Index(IEnumerable<T> values) 40 40 : this() { 41 41 foreach (var value in values) { 42 this.indexes.Add(value .Item2, value.Item1);43 this.values.Add( value.Item1, value.Item2);42 this.indexes.Add(value, nextIndex); 43 this.values.Add(nextIndex, value); 44 44 nextIndex++; 45 45 } … … 47 47 48 48 public uint GetIndex(T value) { 49 uint index = 0; 50 indexes.TryGetValue(value, out index); 51 if (index == 0) { 49 uint index; 50 if (!indexes.TryGetValue(value, out index)) { 52 51 index = nextIndex; 53 52 nextIndex++; … … 60 59 return values[index]; 61 60 } 62 public IEnumerable<T uple<uint, T>> GetValues() {63 return values. Select(x => new Tuple<uint, T>(x.Key, x.Value));61 public IEnumerable<T> GetValues() { 62 return values.Values; 64 63 } 65 64 }
Note: See TracChangeset
for help on using the changeset viewer.