feldmani
asked on
VB.Net queue question
Maybe I am burned out, but I am having trouble figuring this out and don't have the time to play with it.
Dim Current_Node As New Node
Dim Fringe As New Queue
Fringe.Enqueue("EMPTY QUEUE")
Dim Successors() As Node
Current_Node.set_node(0, 0, 0, 0, False)
Fringe.Enqueue(Current_Nod e)
Current_Node.set_node(Cann ibals, Humans, humans_on_top, Savages_On_Bottom, False)
MessageBox.Show(Current_No de.string_ result)
Fringe.Enqueue(Current_Nod e)
Do
Current_Node = Fringe.Dequeue()
How come I am getting errors when I try to dequeue?
Dim Current_Node As New Node
Dim Fringe As New Queue
Fringe.Enqueue("EMPTY QUEUE")
Dim Successors() As Node
Current_Node.set_node(0, 0, 0, 0, False)
Fringe.Enqueue(Current_Nod
Current_Node.set_node(Cann
MessageBox.Show(Current_No
Fringe.Enqueue(Current_Nod
Do
Current_Node = Fringe.Dequeue()
How come I am getting errors when I try to dequeue?
ASKER
The error happens as soon as I enter the loop. I step through the problem. The error I am getting differs, If I enqueue the string first, it says comparing wrong variables. If not, it says queue is empty. Why is it not recognizing that I am putting nodes in the queue?
How could you put in a string first, then dequeue it to a node and expect that to work?
Fringe.Enqueue("EMPTY QUEUE")
Current_Node = Fringe.Dequeue()
Current_Node is a Node not a string
I never see where you are creating a new Node each time before enqueing it. If it is an object, you should use New to create one, then enqueue it, then use new to create another, etc.
Fringe.Enqueue("EMPTY QUEUE")
Current_Node = Fringe.Dequeue()
Current_Node is a Node not a string
I never see where you are creating a new Node each time before enqueing it. If it is an object, you should use New to create one, then enqueue it, then use new to create another, etc.
ASKER
The problem is I am comparing things in a queue that are two objects, nodes, and even though they are the same, it won't recognize them. I believe this has somethign to do with the fact that it is just comparing the reference.
I'm not sure I understand. Are you saying you need to do a CTYPE to cast them to node to do the compare?
Current_Node=CTYPE(Fringe. DEQUEUE,No de)
Current_Node=CTYPE(Fringe.
ASKER
What do you mean? I might need to do a CTYPE. It seems to me my problem comes in when I try to cmopare two things that are the same but it says they aren't. (Hence, it tries to take off the queue twice instead of once. I am assuming the reason that is happenning is because I am comparing pointers(references) instead of values.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No, let me give it a try and I will let you know what comes up. I don't really need the solution anymore per se, since I just used an array list instead (resulting in a huge re-write of code). But it will be nice to know how to do this for the future.
ASKER
SOrry, I made the request before sstory replied. He helped out, so I would like to give him the credits.
I need more info.