package ego.gomoku.core;

import ego.gomoku.entity.Counter;

import java.util.LinkedHashMap;
import java.util.Map;

class Cache {

    Config config;

    GameMap gameMap;

    Counter counter;

    private QueueMap<Long, Boolean> cacheCombo = new QueueMap<>();


    Cache(Config config, GameMap gameMap) {
        this.config = config;
        this.gameMap = gameMap;
        this.counter = counter;
    }

    void recordComboResult(boolean value) {
        if (Config.cacheSize > 0) {
            cacheCombo.put(gameMap.getHashCode(), value);
        }
    }

    Boolean getComboResult() {
        if (Config.cacheSize > 0) {
            if (cacheCombo.containsKey(gameMap.getHashCode())) {
                return cacheCombo.get(gameMap.getHashCode());
            }
        }
        return null;
    }

    public void clear(){
        cacheCombo.clear();
    }

    class QueueMap<K, V> extends LinkedHashMap<K, V> {
        protected boolean removeEldestEntry(Map.Entry eldest) {
            return size() > Config.cacheSize;
        }
    }
}

@@ -23,43 +23,8 @@
 e;%0A%0A
-import ego.gomoku.entity.Counter;%0A%0A
 impo
@@ -51,16 +51,16 @@
 ashMap;%0A
+
 import j
@@ -135,30 +135,8 @@
 p;%0A%0A
-    Counter counter;%0A%0A
     
@@ -274,16 +274,16 @@
 config;%0A
+
         
@@ -310,40 +310,8 @@
 ap;%0A
-        this.counter = counter;%0A
     

remove some code