Priority Queue problem

Hi Everybody.
Can anyone tell me in which order elements of priority queue are sorted.
I have used following code
class Test{
PriorityQueue <strings> pq=new PriorityQueue <Strings>();
pq.add("silpa");
pq.add("swati");
pq.add("roopa");
pq.add("abc");
System.out.println(pq);
System.out.println(pq.poll());
System.out.println(pq.peak());
The output I got is
[abc silpa swathi roopa]
abc
roopa.
Can anybody explain why the collection elements are not sorted ?
I am getting correct output with peek() n poll().According that methods i should get
[abc roopa silpa swathi ]
Explain the reason?

System.out.println(pq);This line prints out the contents of the queue, by implicitly calling pq.toString(), whose behaviour is inherited from AbstractCollection, which therefore has nothing to do with sorting. So you have no valid reason for expecting any particular ordering.

Similar Messages

  • Wanted: Flexible Priority Queue

    Given this class
    class Foo {
    private int STATE, VAL;
    // STATEs are unique, VALs are not
    I want a collection C of Foo objects that supports these operations
    in at most O(log n) time.
    (1) boolean C.contains(Object o);
    --> Using STATE as the comparator
    (2) Object C.get(Object o);
    --> Return a reference to the collection object that equals o,
    again, using STATE as the comparator
    (3) Object C.minExtract();
    --> Remove and return the object with the minimum VAL.
    If there is a tie, choose arbitrarily.
    Operations (1) and (2) call for something like a TreeMap.
    But operation (3) wants to treat the collection as a priority queue,
    which is often implemented as a heap data structure -- which I don't
    see in the classes that come with java.
    In fact all the SortedSet and SortedMap collections seem to require
    unique keys, whereas operation (3) wants to keep the collection sorted
    by non-unique VALs.
    Question: are there off-the-shelf classes I can use to efficiently do what
    I want, or do I need to design it from scratch?
    thanks,
    roy

    DragonMan,
    I agree I may have to create a class which manages two data structures. The first, perhaps, a HashSet. but:
    The other a sorted List of some kind, ordered by VAL.The problem here is "what kind"? As I noted, all of java's sorted collections seem to require unique keys, but VAL is not unique. I suppose I could create my own red-balck tree or heap or whatever, but I'd like to see how much mileage I can get out of java first.
    Currently, I'm considering combining STATE and VAL to make a unique key (since STATE already is unique) whose order however, is dominated by the VAL component.
    roy

  • 6500 strict priority queue size ???

    Hi guys,
    Is it possible to adjust the 6500 line cards strict priority queue size? Most cards assign 85% of thebandwdith to the oridinary queues and 15% to the strict priority queue. It seems that it is not possible to adjust the size of the strict priority queue.
    I have a customer who has numerous T1's encapsulated into IP and the gross amount of traffic is about 200Meg, all of which is real time. If I were to mark this as DSCP 46 (COS 5) it would saturate the strict priorty queue leading not only to performance problems on the T1's but would also starve the rest of the traffic on the 1Gig WAN link.
    Any thoughts guys?
    Regards, Steve

    Hi Paresh,
    Thanks for your reply. I think I didn't explain myself properly. There is a bandwidth allocation of memory for each port. The priority queue gets 15%by default. I have so much priority queue traffic that I want to increase this to 25% because all of it is strict priority (its voice after all). If this canot be done then I will be losing packets of voice since the priorty queue will not be able to accomdate the amount of traffic.
    Best regards, Steve

  • Java priority queue

    Java provides PriorityQueue, and I have gone through its API.
    The implementation of PriorityQueue in Java does not provide method for increase or decrease key,
    and there must be a reason for it.
    But, when i go through books on data strucutre, a lot of them talk about the increase/decrease key function
    of the PriorityQueue.
    So I am just wondering, why is it that increase/decrease function not provided in PriorityQueue. I cannot come up with a reason for it, but i think there must be. Does anybody have any thought on this. Or is it just
    because the designers thought its not needed?
    I checked the source for the Priority Queue and the heapify() method was declared private.

    lupansansei wrote:
    I have used Java's priority queue an I have written my own but I have never come accros the terms "increase or decrease key". Do you mean something like 'upheap' or 'downheap' in relation to a 'heap' implementation meaning move an entry to it correct position if the key changes? If so then one should make the 'key' immutable so that the functions are not needed.
    Yes, i mean 'upheap' or 'downheap' by increase or decrease key. Sorry
    maybe my choice of words was not correct.
    I couldn't get what you mean by 'key' immutable. Can you please explain it. If the key cannot change (i.e. it is immutable) then there is no need to ever change the position of an element.
    >
    Correct. Since the PriorityQueue does not need to implemented using a 'heap' there is no need for the heapify() method to be exposed. If one implemented using a balanced tree or a skip list the heapify() method would not be applicable.I am using PriorityQueue and i need to update the priority of the elements and i was wondering whether to implement the whole queue
    myself or look for a better way of using the PriorityQueue class.
    Do you have any suggestions for efficiently updating the priority of element?I have a priority queue implementation where elements know they are in a heap and know where they are in the heap. By doing this I can modify 'keys' and then move a value to it's correct place in the queue in a very short time. The limitations this feature imposes on the elements and the possibility of corrupting the heap means I don't often use this these days. It is far too error prone.
    These days in my simulations I normally remove an element from the queue, process the element and then create new elements and insert them back in the queue. This sometimes takes 2 lots of Log(n) operations where my specialized priority queue just takes Log(n) operations. The code is just so much more maintainable and I accept the hit.

  • What is Event queue problem?

    HI,
    I have come across JSF document, they mentioned that Event queue
    Problem ins SUN's JSF implementation. what is that?

    You're going to have to be a little more specific.

  • Does the priority queue always work?

    Hi 
    I have a 8Mbp of wan link which sometime gets saturated and I have shaped average this to 8Mbps but i am running vocie on this WAN link and have defined priority for voice with 850kbps under voice class. My question is when the link is not fully utilized, Will the packets from priority queue are always dequeued first as compared to packets sent from from other queus or will the QoS will not do anything here since the link utilization is lot less than what is sepecified in shape average. I am asking this to confirm if the priority queue always help to overcome the issue of jitter if either the link is saturated or not?
    Thanks

    Disclaimer
    The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
    Liability Disclaimer
    In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
    Posting
    You describe PQ and shaping, but the former is usually a part of doing QoS on L2/L3 switches, and the latter on routers.  What device(s) and their IOS versions and the WAN media are you working with?
    On "routers", interfaces generally have FIFO tx-rings, only when they overflow, are packets placed in CBWFQ queues.  Within CBWFQ, LLQ will be dequeued first, but such packets might have already been queued behind other non-LLQ traffic within the interface tx-ring.  (NB: for routers, with tx-rings, when supporting VoIP, you may want to minimize the size of the tx-ring.)
    Shapers, in my experience, are "interesting".  First, I believe many shapers don't account for L2 overhead, but provider CIRs often do.  So unless you shape slower than the nomimal CIR rate, you can send faster than the available bandwidth.  (Often I've found shaping 10 to 15% slower allows for average L2 overhead.)
    Second, shapers work on averages over time intervals.  For VoIP, you'll often want to insure the shaper is using a small Tc, otherwise it will allow FIFO bursts.  (I've found a Tc of 10ms seems to support VoIP fairly well.)
    Third, I suspect some shapers might have their own queues between the interface and the defined policy queues.  If they do, unknown what their queuing organization is or their supported queuing depths.  If this is the case, makes it difficult to engineer QoS.
    Whenever possible, I've found it beneficial to work to avoid using shapers especially for timing sensitive traffic, like VoIP.  In your case, I would suggest, if possible, obtaining 10 Mbps of WAN bandwidth and somewhere passing the traffic through a physical 10 Mbps interface, with a QoS policy.
    But to more directly answer your question, PQ (or LQ) will dequeue its packets next compared to other "peer" queues.  This should always help VoIP for delay and jitter, but there's more involved whether this is necessary and/or whether it's helpful enough when necessary.
    You ask about when a link is saturated, but a link is 100% saturated everytime a packet is being transmitted.  Often link usage is represented in percentages of usage of possible maximum transmission rate over some time period, but when it comes to QoS, 100% utilization might be just fine while 1% utilization is not.  Much, much more information, about your situation, might be needed to offer truly constructive recommendations.

  • Custom  order of priority queue

    I am a novice in Java. I intend to use a priority queue which holds objects. The objects have a string and two integers. I have to order the priority queue based on one of the integer.
    I write syntax according to my understanding please correct me.
    PriorityQueue<Object> pr = new PriorityQueue<Object>();
    comparable(){
    sort(Object.int2)// this is the place where I am confused
    }

    Here's an example:
    public class Caller
        public static void main(String[] args)
            Flight f1 = new Flight( "java", 2, 34 );
            Flight f2 = new Flight( "java", 2, 3 );
            Flight f3 = new Flight( "java", 2, 4 );
            Flight f4 = new Flight( "java", 2, 64 );
            Flight f5 = new Flight( "java", 2, 22 );
            Flight f6 = new Flight( "java", 2, 12 );
            PriorityQueue pq = new PriorityQueue();
            pq.add(f1);
            pq.add(f2);
            pq.add(f3);
            pq.add(f4);
            pq.add(f5);
            pq.add(f6);
            System.out.println(pq.poll());
            System.out.println(pq.poll());
            System.out.println(pq.poll());
            System.out.println(pq.poll());
            System.out.println(pq.poll());
            System.out.println(pq.poll());
    public class Flight implements Comparable
        private String airlinename;
        private int flightnumber;
        private int number;
        public int compareTo(Object o)
            Flight f = (Flight) o;
            return number - f.getNumber();
        public String toString()
            return airlinename + " - " + number;
        public Flight(String airname, int num1, int num2)
            airlinename = airname;
            flightnumber = num1;
            number = num2;
        public String getAirlinename()
            return airlinename;
        public void setAirlinename(String airlinename)
            this.airlinename = airlinename;
        public int getFlightnumber()
            return flightnumber;
        public void setFlightnumber(int flightnumber)
            this.flightnumber = flightnumber;
        public int getNumber()
            return number;
        public void setNumber(int number)
            this.number = number;
    }Got it?

  • OSB 10.3 JMS queue problem: JMSCorrelationID is null

    Hi everybody,
    I am new to OSB/ALSB, and need some help regarding JMS message handling. I am trying to put some input data into a JMS queue( say, reqQueue) and to get the response from another JMS queue(say resQueue). My architecture is:
    OSB proxy service->OSB business service->JMS queue(reqQueue)->BPEL process(through JMS adapter) ->JMS queue(resQueue)->OSB business service->OSB proxy service.
    I have used JMSCorrelationID for response correlation. but my problem is that when I am trying to test the service from proxy service, I am getting the JMSCorrelationId as null in BPEL process as well as in the weblogic server JMS log, and as I am getting the CorrelationId as null, I am unable to correlate the response, so I am not getting any response.
    This is urgent, please help me as soon as possible as possible.
    Thanks in advance.
    Joy

    Sovled it..
    OSB 10.3 JMS queue problem: JMSCorrelationID is null

  • Priority Queues

    hi iam a beginner in java, could you please help me with this code. thanks
    Implement (provide complete Java code) a priority queue using a singly linked list. You may call this class LinkedPriorityQueue. The use of classes contained in the Java Collections framework in the above implementing is strictly forbidden.
    You may need to write a second class, PQNode, which defines the nodes in your linked list. Feel free to implement the PQNode class in anyway that you see fit. However, the LinkedPriorityQueue class should implement all methods and constructors

    Here is the search of the forums
    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%22singly+linked+list%22&col=javaforums&x=23&y=16
    Here is a google search
    http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=%22singly+linked+list%22+java
    Due tomorrow???

  • [svn] 3539: Updated RadioButtonGroup to account for recent changes to LayoutManager priority queue .

    Revision: 3539
    Author: [email protected]
    Date: 2008-10-09 10:58:31 -0700 (Thu, 09 Oct 2008)
    Log Message:
    Updated RadioButtonGroup to account for recent changes to LayoutManager priority queue. The order that a RadioButtonGroup was traversed was always dependent on what order that the radio buttons properties were validated. Since this assumption no longer holds true, we are now very specific about how the group orders the RadioButtons (breadth-first for consistency with Flex 2 and Flex 3).
    Check-in Tests: Pass
    Mustella Tests: (RadioButton, RadioButtonGroup) Pass
    Reviewer: Glenn
    QA: Yes
    Bugs: SDK-17248
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17248
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/RadioButtonGroup.as

    Revision: 3539
    Author: [email protected]
    Date: 2008-10-09 10:58:31 -0700 (Thu, 09 Oct 2008)
    Log Message:
    Updated RadioButtonGroup to account for recent changes to LayoutManager priority queue. The order that a RadioButtonGroup was traversed was always dependent on what order that the radio buttons properties were validated. Since this assumption no longer holds true, we are now very specific about how the group orders the RadioButtons (breadth-first for consistency with Flex 2 and Flex 3).
    Check-in Tests: Pass
    Mustella Tests: (RadioButton, RadioButtonGroup) Pass
    Reviewer: Glenn
    QA: Yes
    Bugs: SDK-17248
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17248
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/RadioButtonGroup.as

  • Low priority and high priority queue

    Hi
    we have high priority and low priority queue's. Functionality wise i know that time critical messages will be sent through high priority queue's and low priority messages will be sent
    through low priority queues. But like to know what technicality makes this separation of
    low priority and high priority queue's ? The crus of the question is what technical setting(s)
    makes the queue as high priority and what technical setting(s) makes the queue as low priority
    queue.
    Thanks
    kumar

    i Michal
    I am talking abt queue prioritization on Integration eninge only.
    I am good with queue prioritization and am able to successfully implement
    the same. We are using only PI7.0.
    My question is what is the technical difference between high priority
    and low priority queues ? what technical setting makes it a high priority
    queue and what technical setting makes a low priority queue ?
    Your answer:
    how the system reacts to new messages if almost all queues are already blocked
    for some types of messages
    My comment: what setting makes the system to behave like that ? what property
    of that queue makes them to behave like that ?
    Thanks
    kumar

  • Egress queueing - priority-queues and queue-sets

    If I use the priority-queue out command on an interface 3750 does this treat queue1 as the priority queue?
    How can I tell which traffic is sent to each queue by default? Or do I have to specifically define it such as
    mls qos srr-queue output dscp-map queue 1 threshold 3 40 41 42 43 44 45 46 47
    I really want dscp 40-47 to go priority and the rest to be spread evenly across the other 3 queues as the vast majority of the rest of the traffic will be 0. Is there a command that lets the other 3 queues be best effort?
    Also, is this an OK config to use with priority-queueing? I don't actually want a large amount of bandwidth for the priority traffic, just for it to be expidited.
    Queueset: 2
    Queue : 1 2 3 4
    buffers : 10 30 30 30
    threshold1: 100 200 100 100
    threshold2: 100 200 100 100
    reserved : 50 50 50 50
    maximum : 400 400 400 400
    Any help very gratefully received.
    Thanks, J

    Sorry, just bouncing this to see if anyone around today can help :)

  • Multiple Priority Queues?

    All,
    I have read that one may configure up to 4 priority queues, not using the Modular QOS CLI (e.g. "priority-list" command, etc).
    For the Modular QOS CLI, PQs are implemented using LLQ ("priority" command), and for this one can only specify a single PQ (though multiple classes may be mapped to this single PQ).
    What I would like to do is to have 2 distinct PQs (as should be possible in the non modular cli case) and also use CBWFQ (e.g. "bandwidth" command) for the rest of the clases. Basically I want to have EF in one PQ, another "special" class in the other PQ (lower priority than EF), and AF classes using CBWFQ.
    Does anyone know of a way to combine the 2 methods (modular and non modular CLI) of configuring LLQ in order to implement such a configuration? I was encouraged to see that heirarchical policies are supported but so far I have not found a way to specify multiple PQs as well as CBWFQ.
    Thanks much!

    There has been alot of discussion on this subject. But it seems that while IOS will allow you to configure multiple priority queues, its not really possible for it to deliver multiple priority queues.
    Which, if you think about it makes sense. A priority queue is just that, it takes priority over all other queues. If you configue 2 priority queues, how would you then then tell the scheduler that these are both priority, but the 2nd is less of a priority?
    One way you can accomplish what you're trying to do:
    1. Create a single "priority" queue for your EF traffic
    2. Use "bandwidth" to guarantee bandwidth to your special class.
    3. Put your AF traffic in class-default and let it "fair-queue".
    Something like this:
    policy-map foo
    class EF
    priority 100
    class Special
    bandwith 50
    class class-default
    fair-queue
    -Geoff

  • Priority queues for external loading

    Hi, I was wondering if there was a way to load multiple external files (via the Loader class) in parrallel, but with a priority queue. That is, I want to load 5 images, but I want image 1 loaded as fast as possible.
    Obviously I could make my own load queue, but if I do that the loading process could easily get hung up on loading a single image.
    I want to be able to run multiple Loader.load()s in parrallel, but assign priority weighting to each of the files.

    i don't know of any way to pause a loading file with flash.   in as3 once a file starts to load you can either let it complete loading or you can stop its load.  if you stop its load and then later want to continue, you must restart from the begining.  i don't believe flash has any way to complete the load of a partially downloaded file.

  • Priority queue out handling.

    We're testing the reference system shown in the figure below.
    System Description
    Four 2960 switches are used for transport;
    Equipment 1 and Equipment 2 exchange packets for synchronization;
    To reach synchronization  Equipment 1 and 2 must exchange data with a very low jitter.
    2960 Configuration details
    Four our test puprose, we're using 100Mbit/s ports (22 and 23) as trunk.
    In order to obtain minimum jitter We performed these configurations:
    We Enabled QoS;
    We Marked Synchronization packets with CoS 7 and DSCP 63;
    We marked other kind of traffic inserted in different ports) with CoS 0;
    We set "trust DSCP" on trunk ports;
    On the trunk ports we mapped traffic with CoS 7/DSCP 63 (and only this) on output queue 1;
    We enabled the expedite queue (priority-queue out).
    Question
    With these settings we aim at forcing our synchronization packtes to precede other kind of traffic and go from Equipment 1 to Equipment 2 with minimum jitter.
    Unfortunately we experienced  high jitter when both synchronization packets and other traffic are sent through the systems.
    What is wrong in our assumptions or configurations?
    What is the real behaviour of the expedit queue?

    Seems the right config.
    This is the my configuration and it works well:
    #global level
    mls qos srr-queue input priority-queue 2 bandwidth 20
    mls qos srr-queue input cos-map queue 1 threshold 3  0 1 2 3 4
    mls qos srr-queue input cos-map queue 2 threshold 3  5 6 7
    mls qos srr-queue output cos-map queue 1 threshold 3  5 6 7
    mls qos srr-queue output cos-map queue 2 threshold 3  4
    mls qos srr-queue output cos-map queue 3 threshold 3  2 3
    mls qos srr-queue output cos-map queue 4 threshold 3  0 1
    mls qos
    #port level
    mls qos trust dscp
    priority-queue out
    What is your IOS version?
    Can you use the 2960 Gigabit port?
    Regards.

Maybe you are looking for

  • Ad hoc Risk Analysis report is returning incorrect Risk Level for some Risks

    We are running GRC AC 10.0 with SP 16.  After application of Support Pack 16, some of our ad hoc risk analysis reports are returning incorrect risk levels.  For example:  Risk F024 Open closed periods and inappropriately post currency or tax entries

  • Changing Inventory from one Account to Another Account

    I have  situation where I need to change the account an inventory came into SBO. It happen with Sales Return A/R. The inventory is in the correct warehouse but Sales Return Account is wrong . I must change that ammount in the account and transfer it

  • Rolling Cluster Upgrade (OES2 to OES11) - GPT partition

    We've got an OES2 SP3 cluster that we'll be rolling cluster upgrading to OES11 SP2. We are currently at max capacity for several of the NSS volumes (2 TB). If I'm reading/interpreting the OES11 SP2 docs correctly: AFTER the cluster upgrade is complet

  • Action won't work on a quickbooks .qbmd file

    I'm trying to create the simplest of actions, and I can't get it to work. I think it has something to do with the type of file (quickbooks *.qbmd file) because the flow will work with other file types. Here's the desired flow: 1. In a designated fold

  • New page trigger always to second page

    Hi All, I have 2 page in my smartforms: Page1: I have to print customer information Page2: I dont have to print cust. information but print data if it overflow the first page. But my issue is if I trigger a new-page if customer changes, Smartforms al