// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

import sign.signlink;

public final class MRUNodes {

    public MRUNodes(int i)
    {
        boolean aBoolean295 = false;
        aBoolean297 = false;
        emptyNodeSub = new NodeSub();
        nodeSubList = new NodeSubList(anInt296);
        initialCount = i;
        spaceLeft = i;
        nodeCache = new NodeCache();
    }

    public NodeSub insertFromCache(long l)
    {
        NodeSub nodeSub = (NodeSub) nodeCache.findNodeByID(l);
        if(nodeSub != null)
        {
            nodeSubList.insertHead(nodeSub);
            anInt299++;
        } else
        {
            anInt298++;
        }
        return nodeSub;
    }

    public void removeFromCache(NodeSub nodeSub, long l, byte byte0)
    {
        try
        {
            if(byte0 != 2)
                aBoolean297 = !aBoolean297;
            if(spaceLeft == 0)
            {
                NodeSub nodeSub_1 = nodeSubList.popTail();
                nodeSub_1.unlink();
                nodeSub_1.unlinkSub();
                if(nodeSub_1 == emptyNodeSub)
                {
                    NodeSub nodeSub_2 = nodeSubList.popTail();
                    nodeSub_2.unlink();
                    nodeSub_2.unlinkSub();
                }
            } else
            {
                spaceLeft--;
            }
            nodeCache.removeFromCache(nodeSub, l, (byte)7);
            nodeSubList.insertHead(nodeSub);
            return;
        }
        catch(RuntimeException runtimeexception)
        {
            signlink.reporterror("47547, " + nodeSub + ", " + l + ", " + byte0 + ", " + runtimeexception.toString());
        }
        throw new RuntimeException();
    }

    public void unlinkAll()
    {
        do
        {
            NodeSub nodeSub = nodeSubList.popTail();
            if(nodeSub != null)
            {
                nodeSub.unlink();
                nodeSub.unlinkSub();
            } else
            {
                spaceLeft = initialCount;
                return;
            }
        } while(true);
    }

    private static int anInt296;
    private boolean aBoolean297;
    private int anInt298;
    private int anInt299;
    private final NodeSub emptyNodeSub;
    private final int initialCount;
    private int spaceLeft;
    private final NodeCache nodeCache;
    private final NodeSubList nodeSubList;
}
