Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/05/17 17:36:50 (8 years ago)
Author:
jkarder
Message:

#2520: worked on persistence

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/Index.cs

    r13347 r14549  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    24 using System.Linq;
    2523using HeuristicLab.PluginInfrastructure;
    2624
     
    3533      this.indexes = new Dictionary<T, uint>();
    3634      this.values = new Dictionary<uint, T>();
    37       nextIndex = 0;
     35      nextIndex = 1;
    3836    }
    3937    public Index(IEnumerable<T> values)
     
    4745
    4846    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)) {
    5149        index = nextIndex;
    5250        nextIndex++;
     
    5755    }
    5856    public T GetValue(uint index) {
    59       return values[index];
     57      return index == 0 ? null : values[index];
    6058    }
    6159    public IEnumerable<T> GetValues() {
Note: See TracChangeset for help on using the changeset viewer.