#ifndef _LINK_CACHE_HEAD
#define _LINK_CACHE_HEAD

struct DataNode {
    void *pVoid;
    int kValue;
    long long startLoc;
    long long endLoc;
    struct DataNode *next;
    int useCount;
};

class LinkCache
{
    public:
        LinkCache();
        virtual ~LinkCache();
        void RealeaseLinCache();
        void InsertNode(void *iPVoid, int iKValue, long long iStartLoc, long long iEndLoc);
        void UpdateNodeSLocByPNode(struct DataNode *pNode, long long iNewStartLoc);
        void UpdateNodeELocByPNode(struct DataNode *pNode, long long iNewEndLoc);
        void DeleteNodeByPVoid(void *iPVoid);
        void DeleteNodeByNodePoint(struct DataNode *iNode);
        int GetCurrentLinkNodeNum();
        void MoveFirst();
        void MoveNext();
        int IfEndLink();
        struct DataNode *QueryCurrentLinkData(void **inVoid, int *iKValue, long long *iStartLoc, long long *iEndLoc);
        struct DataNode *QuerySLocAndELocByPVoid(void *iPVoid, long long *iStartLoc, long long *iEndLoc);

        struct DataNode *GetCurrentNode();
        struct DataNode *QueryNodeByKValue(int ikValue);

    private:
        struct DataNode *mHead, *mTail, *mCurrentNode;
};
#endif
