Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/11/18 10:34:21 (6 years ago)
Author:
bburlacu
Message:

#2886: refactor code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/SearchDataStructure.cs

    r15977 r15993  
    5252  class SearchDataStore : DeepCloneable, IEnumerable<SearchNode> {
    5353    [Storable]
    54     private LruCache<int, SearchNode> storedValues;
    55     //private Dictionary<int, SearchNode> storedValues; // Store hash-references and associated, actual values
     54    private Dictionary<int, SearchNode> storedValues; // Store hash-references and associated, actual values
    5655
    5756    [Storable]
     
    7271    [Storable]
    7372    private int searchDataStructureSize; // storage size for search nodes
    74 
    75     [Storable]
    76     private int cacheSize; // cache for already explored search nodes
    7773
    7874    [ExcludeFromObjectGraphTraversal]
     
    8783    protected SearchDataStore(bool deserializing) : this() { }
    8884
    89     public SearchDataStore(StorageType storageType, int searchDataStructureSize = (int)1e5, int cacheSize = (int)1e5) {
     85    public SearchDataStore(StorageType storageType, int searchDataStructureSize = (int)1e5) {
    9086      this.storageType = storageType;
    9187
    9288      this.searchDataStructureSize = searchDataStructureSize;
    93       this.cacheSize = cacheSize;
    94 
    95       storedValues = new LruCache<int, SearchNode>(this.cacheSize);
     89
     90      storedValues = new Dictionary<int, SearchNode>();
    9691      InitSearchDataStructure();
    9792    }
     
    142137
    143138    protected SearchDataStore(SearchDataStore original, Cloner cloner) : base(original, cloner) {
    144       storedValues = cloner.Clone(original.storedValues);
     139      storedValues = original.storedValues.ToDictionary(x => x.Key, x => cloner.Clone(x.Value));
    145140      storageType = original.storageType;
    146       cacheSize = original.cacheSize;
    147141      searchDataStructureSize = original.searchDataStructureSize;
    148142
     
    204198              var max = sortedSet.Max;
    205199              sortedSet.Remove(max);
    206               storedValues.Remove(max.Item2);
     200              storedValues.Remove(max.Item2); // should always be in sync with the sorted set
    207201            }
    208202            sortedSet.Add(Tuple.Create(prio, hash));
     
    211205            var elem = sortedSet.FirstOrDefault();
    212206            if (elem == null)
    213               return 0;
     207              return default(int);
    214208            sortedSet.Remove(elem);
    215209            return elem.Item2;
     
    226220        // size is the 0-based index of the last used element
    227221        if (priorityQueue.Size == capacity - 1) {
    228           // if the queue is at capacity we have to replace
    229           return;
     222          return; // if the queue is at capacity we have to return
    230223        }
    231224        priorityQueue.Insert(prio, hash);
Note: See TracChangeset for help on using the changeset viewer.