コード例 #1
0
        public int peek()
        {
            int temp = 0;

            if (front != null)
            {
                temp = front.getData();
            }

            return(temp);
        }
コード例 #2
0
        public String display()
        {
            String     nodes = "";
            GreedyNode temp  = front;

            while (temp != null)
            {
                nodes += temp.getData() + " ";
                temp   = temp.getNext();
            }

            return(nodes);
        }
コード例 #3
0
        public bool isVisited(int data)
        {
            bool       flag = false;
            GreedyNode temp = front;

            while (temp != null)
            {
                if (data == temp.getData())
                {
                    flag = true;
                    break;
                }
                else
                {
                    temp = temp.getNext();
                }
            }

            return(flag);
        }
コード例 #4
0
        public int compare()
        {
            int    node      = 0;
            double heuristic = 0;

            if (front != null)
            {
                GreedyNode temp = front.getNext();

                heuristic = front.getFunction();
                node      = front.getData();
                while (temp != null)
                {
                    if (temp.getFunction() < heuristic)
                    {
                        heuristic = temp.getFunction();
                        node      = temp.getData();
                    }

                    temp = temp.getNext();
                }
            }
            return(node);
        }