コード例 #1
0
        ///
        ///<summary>The remove method takes a CacheNode type input cacheNode. If cacheNode has a previous node, then
        /// assigns cacheNode's next node as previous node's next node. If cacheNode has not got a previous node, then
        /// assigns its next node as head node. Moreover, if cacheNode has a next node, then assigns cacheNode's
        /// previous node as next node's previous node; if not assigns tail node's previous node as tail. By doing so
        /// it removes the cacheNode from doubly {@link java.util.LinkedList}.</summary>
        ///
        ///<param name="cacheNode"> {@link CacheNode} type input to remove.</param>
        ///
        public void Remove(CacheNode <TKey, TData> cacheNode)
        {
            var previous = cacheNode.GetPrevious();
            var next     = cacheNode.GetNext();

            if (previous != null)
            {
                previous.SetNext(next);
            }
            else
            {
                _head = _head.GetNext();
            }

            if (next != null)
            {
                next.SetPrevious(previous);
            }
            else
            {
                _tail = _tail.GetPrevious();
            }
        }