Changeset 14673


Ignore:
Timestamp:
02/14/17 15:29:14 (4 years ago)
Author:
epitzer
Message:

#2727 improve AMT's size with history (use same rollback semantic) and add comparison value with traditional arrays

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistentDataStructures/HeuristicLab.Data/3.3/PersistentDataStructures/Implementations/ArrayMappedTrie.cs

    r14657 r14673  
    244244      var nodes = new Dictionary<Node, UInt16>();
    245245      AddNodeSizeRecursively(root, nodes);
    246       var size = nodes.Sum(kvp => (long) kvp.Value);
    247       if (oldRoots != null) {
    248         foreach (var node in oldRoots) {
    249           AddNodeSizeRecursively(node.Item1, nodes);
    250         }
    251       }
    252       var sizeWithHistory = nodes.Sum(kvp => (long)kvp.Value);
    253       Console.WriteLine("size = {0}, size with history = {1}", size, sizeWithHistory);
    254       return sizeWithHistory;
     246      var prev = Rollback();
     247      while (prev != null) {
     248        AddNodeSizeRecursively(prev.root, nodes);
     249        prev = prev.Rollback();
     250      }
     251      return nodes.Sum(kvp => (long) kvp.Value);
     252    }
     253
     254    public long TheoreticalSizeOfArraysWithHistory() {
     255      long total = Count;
     256      var prev = Rollback();
     257      while (prev != null) {
     258        total += prev.Count;
     259        prev = prev.Rollback();
     260      }
     261      return total;
    255262    }
    256263
Note: See TracChangeset for help on using the changeset viewer.