Ejemplo n.º 1
0
    /*
     * pushAtTheEnd method will take a node and push it at the back of the lsit
     * parameter:	(AIFringeSearchNode)nodeToPush is the node the caller wants at the back of the list
     * Return:	none
     */
    public void pushAtTheEnd(AIFringeSearchNode nodeToPush)
    {
        if (frontOfList == null)
        {
            nodeToPush.setNextNode(frontOfList);
            frontOfList = nodeToPush;
            numberOfNodesHeld++;
            return;
        }
        AIFringeSearchNode tempNode = getNodeAtIndex(getSize() - 1);

        nodeToPush.setNextNode(tempNode.getNextNode());
        tempNode.setNextNode(nodeToPush);
        numberOfNodesHeld++;
    }
Ejemplo n.º 2
0
    /* deleteNodeOfId deletes the node from the list that is holding a polygon with a certain id
     * Parameter: (int) idToDelete is the id of the polygon being held by the node to be deleted
     * Return: none
     */
    public void deleteNodeOfId(int idToDelete)
    {
        AIFringeSearchNode tempFront = frontOfList;

        if (frontOfList != null)
        {
            if (doesIDMatch(frontOfList.getPolygon().getID(), idToDelete) == true)
            {
                frontOfList = frontOfList.getNextNode();
                numberOfNodesHeld--;
                return;
            }
            AIFringeSearchNode tempback = tempFront.getNextNode();
            while ((tempback.getNextNode() != null) && (doesIDMatch(tempback.getPolygon().getID(), idToDelete) == false))
            {
                tempFront = tempback;
                tempback  = tempFront.getNextNode();
            }
            if (doesIDMatch(tempback.getPolygon().getID(), idToDelete) == true)
            {
                tempFront.setNextNode(tempback.getNextNode());
            }
            numberOfNodesHeld--;
        }
    }
Ejemplo n.º 3
0
    /*
     * addAfter will make a new polygon and add it right after the node being passed in
     * Parameter:	(AIPolygon)polygonToAdd is the polygon for the new node
     *              (AIFringeSearchNode)parentNode is the node that will be the parent of this node
     *              (float)gCostToAdd is the cost to get to this node
     * Return:	none
     */
    public void addAfter(AIPolygon polygonToAdd, AIFringeSearchNode nodeToAddAfter, float gCostToAdd)
    {
        AIFringeSearchNode tempNode = new AIFringeSearchNode(polygonToAdd, nodeToAddAfter, gCostToAdd, goalPosition);

        tempNode.setNextNode(nodeToAddAfter.getNextNode());
        nodeToAddAfter.setNextNode(tempNode);
        numberOfNodesHeld++;
    }
Ejemplo n.º 4
0
    /*
     * enqueue method will place a node in the front of the list
     * Parameter:	(AIPolygon)polygonToAdd is the polygon for the new node
     *              (AIFringeSearchNode)parentNode is the node that will be the parent of this node
     *              (float)gCostToAdd is the cost to get to this node
     * Return:	none
     */
    public void enqueue(AIPolygon polygonToAdd, AIFringeSearchNode parentNode, float gCostToAdd)
    {
        AIFringeSearchNode tempNode = new AIFringeSearchNode(polygonToAdd, parentNode, gCostToAdd, goalPosition);

        tempNode.setNextNode(frontOfList);
        frontOfList = tempNode;
        numberOfNodesHeld++;
    }