We help IT Professionals succeed at work.

VB.Net queue question

feldmani
feldmani asked
on
309 Views
Last Modified: 2010-04-23
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_Node)
        Current_Node.set_node(Cannibals, Humans, humans_on_top, Savages_On_Bottom, False)
        MessageBox.Show(Current_Node.string_result)
        Fringe.Enqueue(Current_Node)
        Do
            Current_Node = Fringe.Dequeue()

How come I am getting errors when I try to dequeue?
Comment
Watch Question

CERTIFIED EXPERT

Commented:
hard to tell. You need to tell us what error you are getting.  If you dequeue one time before the do loop does it give you an error? If so what? If not, it doesn't like being in the loop in whatever way you are using it.

I need more info.

Author

Commented:
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?
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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.  
CERTIFIED EXPERT

Commented:
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,Node)

Author

Commented:
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.
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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.  

Author

Commented:
SOrry, I made the request before sstory replied.  He helped out, so I would like to give him the credits.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.