About 42,400 results
Open links in new tab
  1. dequeue and enqueue methods in queue implementation

    Dec 1, 2016 · @Joe When the queue is empty and you enqueue an item, it will go straight into the if statement of the enqueue() method, right? If you don't put a return statement, the code will continue to execute the lines outside of if statement. By return I mean that "the item has been equeued, end the method here, and return to where the method was called ...

  2. Enqueue, Dequeue and ViewQueue in Java - Stack Overflow

    Jul 9, 2013 · Java queues don't have enqueue and dequeue methods, these operations are done using the following methods: Enqueuing: add(e): throws exception if it fails to insert the object; offer(e): returns false if it fails to insert the object; Dequeuing: remove(): throws exception if the queue is empty; poll(): returns null if the queue is empty

  3. java - Enqueue List method - Stack Overflow

    Mar 21, 2013 · Is there a way to enqueue this method faster? I'm trying to add performance test to this method and wondering if there is alternative for this. import java.util.ArrayList; import java.util.Lis...

  4. Difference between "enqueue" and "dequeue" - Stack Overflow

    Mar 5, 2015 · Enqueue and Dequeue tend to be operations on a queue, a data structure that does exactly what it sounds like it does. You enqueue items at one end and dequeue at the other, just like a line of people queuing up for tickets to the latest Taylor Swift concert (I was originally going to say Billy Joel but that would date me severely).

  5. what is a more efficient way to implement enqueue in Java

    Nov 17, 2013 · Use a LinkedList instead of an ArrayList. You don't need indexed access in a queue, but you do need fast enqueue/dequeue. If you need indexed access. It isn't really a queue at all. And just use the add() method, don't create a whole new queue every time. Your enqueue() method should return 'this', or void.

  6. Understanding the enqueue method for Linked List Queue

    Sep 23, 2015 · Im having trouble understanding the code for the enqueue method for a linkedlist queue. I understand the dequeue(), isEmpty(), First() and size(). Firstly here is there LinearNode class to create the new node objects: public class LinearNode<T> { private T element; private LinearNode<T> next; /** * Constructor: Creates an empty node.

  7. java - Enqueue method in CircularArrayQueue class - Stack Overflow

    Jan 18, 2014 · rear = (rear+1) % queue.length; achieves circularity. As CircularArrayQueue class name suggests it is circular. It means that when the last element (queue.length-th) is reached it begins to insert elements from the beginning.

  8. enqueue a linked list - java - Stack Overflow

    Create enqueue method; In enqueue method, first check if head SnocList is empty (or == null). If so, just make the head SnocList a new SnocList that contains your passed-in character and the reference to the l SnocList. l would be null because there would be no other SnocLists in the linked list. Then, return to end execution of the method.

  9. Implement a queue using an array - Java - Stack Overflow

    Mar 5, 2013 · Your implementation may not be the most efficient way of using an array to implement a queue, but given that you've decided to implement it this way, your enqueue method is a bit more complex than it need be. You have a field sz that can be used to determine where the new entry has to be put rather than checking through to find the first non ...

  10. java - Queue implementation, enqueue method not working

    Feb 22, 2013 · I am trying to write my own queue class. My enqueue method is only enqueue-ing one object and then if I try to enqueue anything else, its almost as if its ignoring it. Here is my code: public cl...

Refresh