Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7737 for trunk


Ignore:
Timestamp:
04/17/12 16:59:39 (13 years ago)
Author:
epitzer
Message:

#1722 add missing Hits property in cloning constructor and clean up code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/EvaluationCache.cs

    r7259 r7737  
    151151      : base(original, cloner) {
    152152      SetCacheValues(original.GetCacheValues());
     153      Hits = original.Hits;
    153154      RegisterEvents();
    154155    }
     
    167168    #region Event Handling
    168169    private void RegisterEvents() {
    169       CapacityParameter.Value.ValueChanged += new EventHandler(Value_ValueChanged);
    170     }
    171 
    172     void Value_ValueChanged(object sender, EventArgs e) {
     170      CapacityParameter.Value.ValueChanged += new EventHandler(CapacityChanged);
     171    }
     172
     173    void CapacityChanged(object sender, EventArgs e) {
    173174      if (Capacity < 0)
    174175        throw new ArgumentOutOfRangeException("Cache capacity cannot be less than zero");
     
    190191
    191192    public double GetValue(SolutionMessage message, Evaluator evaluate) {
    192       CacheEntry entry = new CacheEntry(message.ToString());
    193       LinkedListNode<CacheEntry> node;
     193      var entry = new CacheEntry(message.ToString());
    194194      bool lockTaken = false;
    195195      bool waited = false;
     
    197197        Monitor.Enter(cacheLock, ref lockTaken);
    198198        while (true) {
     199          LinkedListNode<CacheEntry> node;
    199200          if (index.TryGetValue(entry, out node)) {
    200201            list.Remove(node);
     
    243244    private void Trim() {
    244245      while (list.Count > Capacity) {
    245         LinkedListNode<CacheEntry> item = list.First;
     246        var item = list.First;
    246247        list.Remove(item);
    247248        index.Remove(item.Value);
     
    260261        index = new Dictionary<CacheEntry, LinkedListNode<CacheEntry>>();
    261262        foreach (var kvp in value) {
    262           var entry = new CacheEntry(kvp.Key);
    263           entry.Value = kvp.Value;
     263          var entry = new CacheEntry(kvp.Key) { Value = kvp.Value };
    264264          index[entry] = list.AddLast(entry);
    265265        }
Note: See TracChangeset for help on using the changeset viewer.