- Timestamp:
- 04/17/12 16:59:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/EvaluationCache.cs
r7259 r7737 151 151 : base(original, cloner) { 152 152 SetCacheValues(original.GetCacheValues()); 153 Hits = original.Hits; 153 154 RegisterEvents(); 154 155 } … … 167 168 #region Event Handling 168 169 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) { 173 174 if (Capacity < 0) 174 175 throw new ArgumentOutOfRangeException("Cache capacity cannot be less than zero"); … … 190 191 191 192 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()); 194 194 bool lockTaken = false; 195 195 bool waited = false; … … 197 197 Monitor.Enter(cacheLock, ref lockTaken); 198 198 while (true) { 199 LinkedListNode<CacheEntry> node; 199 200 if (index.TryGetValue(entry, out node)) { 200 201 list.Remove(node); … … 243 244 private void Trim() { 244 245 while (list.Count > Capacity) { 245 LinkedListNode<CacheEntry>item = list.First;246 var item = list.First; 246 247 list.Remove(item); 247 248 index.Remove(item.Value); … … 260 261 index = new Dictionary<CacheEntry, LinkedListNode<CacheEntry>>(); 261 262 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 }; 264 264 index[entry] = list.AddLast(entry); 265 265 }
Note: See TracChangeset
for help on using the changeset viewer.