I'm having difficulty printing elements out in the order they were entered. My program is reading a .txt file.
I'm using a Queue to store the elements which I thought was a FIFO. But when I run my program I get the elements in reverse order. I thought I'd try a Priority Que but instead I was rewarded with an alphabetically sorted order.
If anyone has any ideas or directions I should go to find the answer I'd really appreciate it. Thanks.
public Iterable<Key> keys()
{
Queue<Key> queue = new Queue<Key>();
for (Node x = first; x != null; x = x.next)
queue.enqueue(x.key);
return queue;
}
Aucun commentaire:
Enregistrer un commentaire