Ejemplo n.º 1
0
        //----------------------------------------------------------------------
        // Base Methods
        //----------------------------------------------------------------------
        public DLink baseAdd()
        {
            //calls addtofront in DLink
            // derived add method will have parameters

            //Check if there are any nodes in reserve
            if (this.poHeadReserve == null)
            {
                //perform a refill
                this.privFillReservePool(this.growthRate);
            }

            // Now that we are guarenteed that the reserve is not-empty we can pull
            DLink pLink = DLink.PullFromFront(ref this.poHeadReserve);

            //Clean the node of data and references to other DLinks
            pLink.Clear();
            this.derivedWash(pLink);


            // initialize
            DLink.AddToFront(ref this.poHeadActive, pLink);

            // update counters
            this.mNumActiveNodes++;
            this.mNumReserveNodes--;

            return(pLink);
        }
Ejemplo n.º 2
0
        protected DLink BaseAdd()
        {
            // If any node doesn't exist in reserve list.
            if(this.pReserve == null)
            {
                // Refill the reserve list by the growthSize
                this.PrivFillReservedPool(this.growthSize);
            }

            // Always take from the reserve list
            DLink pLink = DLink.PullFromFront(ref this.pReserve);
            Debug.Assert(pLink != null);

            // Wash it
            this.DerivedWash(pLink);

            // Update stats
            this.mNumActive++;
            this.mNumReserve--;
            if (this.mNumActive > this.maximumNumActive)
            {
                this.maximumNumActive = this.mNumActive;
            }

            // copy to active
            DLink.AddToFront(ref this.pActive, pLink);
            return pLink;
        }
Ejemplo n.º 3
0
        protected DLink BaseAddToPosition(DLink pNode)
        {
            if (this.poReserve == null)
            {
                this.PrivFillReservedPool(this.mDeltaGrow);
            }

            DLink pLink = DLink.PullFromFront(ref this.poReserve);

            Debug.Assert(pLink != null);

            // Wash it
            this.DerivedWash(pLink);

            // Update stats
            this.mNumActive++;
            this.mNumReserved--;

            // copy to active
            if (pNode == null)
            {
                DLink.AddToFront(ref this.poActive, pLink);
            }
            else
            {
                DLink.AddToBehind(ref pNode, pLink);
            }

            // YES - here's your new one (its recycled from reserved)
            return(pLink);
        }
Ejemplo n.º 4
0
        private static DLink privPullFromFront(ref DLink pHead)
        {
            // There should always be something on list
            Debug.Assert(pHead != null);

            DLink pNode;

            pNode = DLink.PullFromFront(ref pHead);

            Debug.Assert(pNode != null);
            return(pNode);
        }
Ejemplo n.º 5
0
        protected DLink GrabNode()
        {
            if (this.NumReserve == 0)
            {
                this.PrivReFill(this.growth);
            }

            DLink pDLink = DLink.PullFromFront(ref this.poReserve);

            this.NumReserve--;

            this.DerivedWash(pDLink);

            this.NumActive++;
            return(pDLink);
        }
Ejemplo n.º 6
0
        protected DLink getNewNode()
        {
            // when there is no reversed node
            if (this.pReserved == null)
            {
                // refill reversed list
                this.fillNodesToReservedList(this.mNumGrow);
            }

            // get the node to add from the reserve list and update states
            DLink newNode = DLink.PullFromFront(ref this.pReserved);

            Debug.Assert(newNode != null);
            this.mNumReserved--;

            // reset the node
            this.derivedReset(newNode);

            return(newNode);
        }
Ejemplo n.º 7
0
        protected DLink BasePopNode()
        {
            // If any node doesn't exist in reserve list.
            if (this.pReserve == null)
            {
                // Refill the reserve list by the growthSize
                this.PrivFillReservedPool(this.growthSize);
            }

            // Always take from the reserve list
            DLink pLink = DLink.PullFromFront(ref this.pReserve);
            Debug.Assert(pLink != null);

            // Wash it
            this.DerivedWash(pLink);

            // Update stats
            this.mNumReserve--;

            return pLink;
        }
Ejemplo n.º 8
0
        protected DLink BaseAdd()
        {
            // refill Reserve List if empty
            if (this.NumReserve == 0)
            {
                this.PrivReFill(this.growth);
            }

            //pull from front of reserve list
            DLink pDlink = DLink.PullFromFront(ref this.poReserve);

            this.NumReserve--;

            //clean the notecard
            this.DerivedWash(pDlink);

            //then add to front of active list
            DLink.AddToFront(ref this.poActive, pDlink);


            this.NumActive++;

            return(pDlink);
        }