コード例 #1
0
    /*
     * dequeue method will remove the top Node from the Queue and return the AIPolygon being
     *      held inside the node being removed
     * Parameters:	None
     * Return:	(AIPolygon)
     *							null if the queue is empty
     *							the AIPolygon being held if the queue is not empty
     */
    public AIPolygon dequeue()
    {
        AIPolygonNode temp = front;

        front = temp.getNextNode();
        size--;
        return(temp.getPolygon());
    }
コード例 #2
0
    /*
     *	getPolygonAtIndex will find a AIPolygonNode at a certian point inside the Queue
     *		and return the AIPolygon being held inside the node. It will not remove the
     *		Node from the Queue
     *	Parameters:	(int)index is the index in the Queue that the caller wants sent back
     *	Return:			(AIPolygon)
     *									the AIPolygon at the index in the Queue
     */
    public AIPolygon getPolygonAtIndex(int index)
    {
        if (index == 0)
        {
            return(front.getPolygon());
        }
        AIPolygonNode temp = front;

        for (int count = 0; count < index; count++)
        {
            temp = temp.getNextNode();
        }
        return(temp.getPolygon());
    }
コード例 #3
0
    /*
     *	deleteNodeOfID method will delete the node at a certian index in the Queue. It will Not
     *			return the AIPolygon being held or the AIPolygonNode
     *	Parameters:	(int)idToDelete is the position at which the caller want the node to delete
     *	Return:	None
     */
    public void deleteNodeOfID(int idToDelete)
    {
        AIPolygonNode tempFront = front;

        if (front != null)
        {
            if (front.doesIDMatch(idToDelete) == true)
            {
                front = front.getNextNode();
                return;
            }
            AIPolygonNode tempBack = front.getNextNode();
            while (tempBack.getNextNode() != null && tempBack.doesIDMatch(idToDelete) == false)
            {
                tempFront = tempBack;
                tempBack  = tempFront.getNextNode();
            }
            if (tempBack.doesIDMatch(idToDelete) == true)
            {
                tempFront.setNextNode(tempBack.getNextNode());
                return;
            }
        }
    }