- Timestamp:
- 01/05/17 17:36:50 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/Index.cs
r13347 r14549 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Linq;25 23 using HeuristicLab.PluginInfrastructure; 26 24 … … 35 33 this.indexes = new Dictionary<T, uint>(); 36 34 this.values = new Dictionary<uint, T>(); 37 nextIndex = 0;35 nextIndex = 1; 38 36 } 39 37 public Index(IEnumerable<T> values) … … 47 45 48 46 public uint GetIndex(T value) { 49 uint index ;50 if ( !indexes.TryGetValue(value, out index)) {47 uint index = 0; 48 if (value != null && !indexes.TryGetValue(value, out index)) { 51 49 index = nextIndex; 52 50 nextIndex++; … … 57 55 } 58 56 public T GetValue(uint index) { 59 return values[index];57 return index == 0 ? null : values[index]; 60 58 } 61 59 public IEnumerable<T> GetValues() {
Note: See TracChangeset
for help on using the changeset viewer.