Results 1 to 6 of 6

Thread: Instantiating a queue class

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    Instantiating a queue class

    Hello,
    I know how to use a queue that enables simple to add or remove an item and retrieve the first element entered into it. I had to use that interface Tail java.util. But how can I instantiate the queue?
    Code:
    private Queue fileAttente = new ??();
    This is what I want to know, If I am not wrong then this should be similar to something like this.
    Last edited by Logan 2; 04-02-2010 at 04:14 AM.

  2. #2
    Join Date
    Nov 2009
    Posts
    518

    Re: Instantiating a queue

    Hi,
    In the javadoc, you list all classes that implement an interface that
    All Known Implementing Classes:
    AbstractQueue,
    ArrayBlockingQueue,
    ArrayDeque,
    ConcurrentLinkedQueue,
    DelayQueue,
    LinkedBlockingDeque,
    LinkedBlockingQueue,
    LinkedList,
    PriorityBlockingQueue,
    PriorityQueue,
    SynchronousQueue
    If you need more information on this, you can visit the sun api documentation.

  3. #3
    Join Date
    Dec 2009
    Posts
    211

    Re: Instantiating a queue

    Hello,
    If it is a linked list, it does not fit because I really want to implement a simple queue. It would suit me if it was a simple queue implemented using a linked list (adding lead does not interest me for example). What I want to do is to retrieve documents in a queue and handle them later on a FIFO (First In First Out). Suppose that several documents are saved in my queue. And although the first recorded being the first treaty etc. I hope to be clear. And in my case, what is the best implementation of the interface queue?

  4. #4
    Join Date
    Nov 2009
    Posts
    356

    Re: Instantiating a queue class

    Hello,
    I do not have an ideas how to do it in java, but in c++ it can be done some what like this
    Code:
    class testcl
    {
        public:
                testcl(); // constructor
                // other methods
        private:
                std::priority_queue<orClass> queue;
    };
    As, I am a C++ programmer, i know the c++ method to do it, see if you get knowledge or some basic idea about how to do it.

  5. #5
    Join Date
    Dec 2009
    Posts
    211

    Re: Instantiating a queue class

    Hello,
    I thought that the methods push () and pop () was intended to batteries (LIFO) and not to queue (FIFO).
    Also, when I do:
    Code:
    private Queue queue = <Document> new LinkedList <Document>();
    I do not have the methods push () and pop () from my queue "queue".
    I was wrong or is it you should read the Javadoc?

  6. #6
    Join Date
    Dec 2009
    Posts
    192

    Re: Instantiating a queue class

    Hello,
    A few days before even i was trying a program similar like this, that is a code to instantiate a queue object. I found it necessary to use a PriorityQueue, it implements a simple queue.
    Code:
    private Queue queue = <Document> new PriorityQueue <Document>();
    This helped me for my coding, if you are interested then you can try the following. But i do not know for what purpose you are going to use it. Still, you can try it.

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. Replies: 5
    Last Post: 12-02-2010, 06:23 PM
  3. Debug class and Trace class Difference
    By Amaresh in forum Software Development
    Replies: 5
    Last Post: 22-01-2010, 10:00 AM
  4. Ultra solid drives:Imation M-Class and S-Class
    By Regina in forum Portable Devices
    Replies: 1
    Last Post: 03-04-2009, 10:34 AM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,027,535.12425 seconds with 16 queries