Qos using priority queue drops

I have following config for Qos.
Basically Access-list match the voip/signalling traffic & put that in High queue. I am trying to figure without hight utilization why I am seeing output drops in high queue.
7206#sh int s5/1/5:0
Serial5/1/5:0 is up, line protocol is up
Hardware is PA-MC-2T3+
Description: T1
Internet address is 172.17.133.105/30
MTU 1500 bytes, BW 1536 Kbit, DLY 20000 usec,
reliability 255/255, txload 24/255, rxload 23/255
Encapsulation HDLC, crc 16, loopback not set
Keepalive set (10 sec)
Last input 00:00:06, output 00:00:00, output hang never
Last clearing of "show interface" counters 01:58:03
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 1800
Queueing strategy: priority-list 4
Output queue (queue priority: size/max/drops):
high: 0/20/1764, medium: 0/20/0, normal: 0/15/36, low: 0/15/0
5 minute input rate 143000 bits/sec, 82 packets/sec
5 minute output rate 145000 bits/sec, 83 packets/sec
734269 packets input, 148368640 bytes, 0 no buffer
Received 708 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
734855 packets output, 148838576 bytes, 0 underruns
0 output errors, 0 collisions, 0 interface resets
0 output buffer failures, 0 output buffers swapped out
0 carrier transitions no alarm present
Timeslot(s) Used: 1-24, subrate: 1536Kb/s, transmit delay is 0 flags
non-inverted data
==============================================================================
7200#sh run int s2/1/5:0
Building configuration...
Current configuration : 254 bytes
interface Serial2/1/5:0
description T1
ip address x.x.x.x
no ip redirects
no ip unreachables
no ip proxy-arp
no snmp trap link-status
priority-group 4
no cdp enable
end
====================================================================================
Define access-list to match voice/signalling traffic
access-list 140 permit udp any any range 1024 1151
access-list 140 permit udp any any range 16384 32767
access-list 140 permit udp any any eq 2427
access-list 140 permit udp any any eq 2429
access-list 140 permit udp any any eq 5060
priority-list 4 protocol ip high list 140
priority-list 4 queue-limit 20 20 15 15

Hi,
your queue limit is 20 packets. This can explain the behaviour. If there are 20 packets in the queueing system waiting to be serviced any newly arriving packet will be dropped.
Basically you can have drops in any queue in any queueing system if there is a permanent overload situation. There is no magic trick, if you f.e. permanently send 2 Mbps voip towards a T1. There will be drops.
QoS does not create resources, it just distributes them among your important traffic classes.
Besides this I also would suggest you to use class based queueing based on Modular QoS CLI (MQC). It is more flexible and precise than the old legacy methods like priority queueing, which you are using. On the other hand, if this is sufficient for you, why not.
Regards, Martin

Similar Messages

  • Priority-queue out and 3750

    Does 3750 switch still need command "priority-queue out"? I noticed when I apply " auto qos voip cisco-phone", it doesn't auto generate "priority-queue out" any more. I know this command is useful in 3550 to prioritize the voice traffic.

    This release contains these new switch features or enhancements:
    Quality of service (QoS) egress priority queue on a port. Shaped round robin (SRR) services the priority queue until it is empty before servicing the other three queues. You enable the egress priority queue by using the priority-queue out interface configuration command.
    QoS Differentiated Services Code Point (DSCP) transparency allows the user to prevent the switch from rewriting the DSCP field in the user IP packet when QoS is enabled.
    http://www.cisco.com/univercd/cc/td/doc/product/lan/cat3750m/12114ax/ol464603.htm

  • About priority queue

    I tried to use priority queue which I saw on the JavaTM 2 Platform
    Standard Ed. 5.0(on the web),but when I tried to create a priority queue for my work(PriorityQueue myQ = new PriorityQueue();)the compiler complaint about that,
    "C:\Program Files\Xinox Software\JCreator LE\MyProjects\Trypq\Trypq.java:7: cannot resolve symbol"
    and then I found that I can not find this priority queue class in JavaTM 2 Platform Std. Ed. v1.4.2,so what's wrong with this 2 different API,does it mean that I have to create the priority queue class by myself,because my work can only base on JavaTM 2 Platform Std. Ed. v1.4.2???
    can you help?
    thanks!

    The feature was added in the latest release of Java. If you want to use it, you have to have the latest release.
    Some of the concurrency features added in 1.5 (J2SE 5.0) were taken from Doug Lea's util.concurrent library, but I don't believe this was one of them. For those that were you have the option of using Doug's excellent library with pre 1.5 code.
    You could also write your own, but I wouldn't particularly recommend it if you can upgrade to J2SE 5.0
    Dave.

  • QoS - output queues dropped.

    Hi, i have a phone thats no working fine, it unregister all the time from the sip server. 
    The port connected to the phone has output queues dropped on queue 1. ¿That's normal? ¿What could be the cause that there drop packet?
    Thanks!
    I have this configuration for Qos on the switch port:
    interface FastEthernet0/15
     switchport mode access
     switchport voice vlan 15
     priority-queue out
     mls qos trust cos
     spanning-tree portfast
    sh mls qos int fa0/15 st
    FastEthernet0/15 (All statistics are in packets)
      dscp: incoming
      0 -  4 :      184994            0            0            0            0
      5 -  9 :           0            0            0            0            0
     10 - 14 :           0            0            0            0            0
     15 - 19 :           0            0            0            0            0
     20 - 24 :           0            0            0            0            0
     25 - 29 :           0      2298420            0            0            0
     30 - 34 :           0            0            0            0            0
     35 - 39 :           0            0            0            0            0
     40 - 44 :           0            0            0            0            0
     45 - 49 :           0      4806226            0        16934            0
     50 - 54 :           0            0            0            0            0
     55 - 59 :           0            0            0            0            0
     60 - 64 :           0            0            0            0
      dscp: outgoing
      0 -  4 :     8134930            0            0            0            0
      5 -  9 :           0            0            0            0            0
     10 - 14 :           0            0            0            0            0
     15 - 19 :           0            0            0            0            0
     20 - 24 :           0            0            0            0            0
     25 - 29 :           0            0            0            0            0
     30 - 34 :           0            0            0            0            0
     35 - 39 :           0            0            0            0            0
     40 - 44 :         861            0            0            0            0
     45 - 49 :           0            0            0            5            0
     50 - 54 :           0            0            0            0            0
     55 - 59 :           0            0            0            0            0
     60 - 64 :           0            0            0            0
      cos: incoming
      0 -  4 :      875001            0            0            0            0
      5 -  7 :     6544104            0            0
      cos: outgoing
      0 -  4 :     8781009            3            6            1            2
      5 -  7 :      275463            5        17983
      output queues enqueued:
     queue:    threshold1   threshold2   threshold3
     queue 0:      292615           0           0
     queue 1:     8562114       44049     5388502
     queue 2:           0           0           0
     queue 3:       17982           0      183824
      output queues dropped:
     queue:    threshold1   threshold2   threshold3
     queue 0:           0           0           0
     queue 1:        5349           0           0
     queue 2:           0           0           0
     queue 3:           0           0           0
    Policer: Inprofile:            0 OutofProfile:            0

    Martin,
    Refer to this link you need to modify your buffers etc. :http://www.cisco.com/c/en/us/support/docs/switches/catalyst-3750-series-switches/116089-technote-switches-output-drops-qos-00.html
    -Terry
    Please rate all helpful posts

  • Priority Queue using Vector

    I am trying to develop Priority Queue using vector. For inserting elements I need to check if the inserted objects have greater key I want to shift them. In short, I want to store objects in vector in sorted manner (sort by key). I need help for that.
    The code I have created so far is like this:
    import PriorityQueue;
    import java.util.*;
    import java.io.*;
    public class PQItem
         private Object e;
         private int k;
         public PQItem(int key, Object element)
              k=key;
              e=element;
         public int key(){ return k;}
         public Object elelment(){ return e;}
         public void setkey(int key){k=key;}
         public void setElement(Object element){e=element;}
         public static void main(String args[])
              FileReader fr;
              fr = openfile();
         public static FileReader openfile()
              String line,name,file="test.txt";
              int vsize,k1,i1=0;
              boolean flag;
              Object e1,e2;
              //Vector v = new Vector();
              PriorityQueue q=new PriorityQueue();
              try
                   FileReader fr=new FileReader(file);
                   BufferedReader inFile = new BufferedReader(fr);
                   String del=",";
                   line=inFile.readLine();
                   StringTokenizer tokenizer=new StringTokenizer(line,del);
                   while(line!=null)
                        tokenizer = new StringTokenizer(line,del);
                        k1 = Integer.parseInt(tokenizer.nextToken());
                        e1 = tokenizer.nextToken();
                        //System.out.println(line);
                        q.InsertItem(line,i1);
                        line=inFile.readLine();
                        i1++;
                   flag=q.isEmpty();
                   System.out.println(flag);
                   vsize=q.size();
                   System.out.println(+vsize);
                   e2=q.last();
                   System.out.println(e2);
              }//try
              catch(FileNotFoundException exception)
                   System.out.println("The File "+file+" was not found");
              catch(IOException exception)
                   System.out.println(exception);
              return null;
         }//filereader
    //The other file is
    import java.util.*;
    public class PriorityQueue
         private Object[] a;
         Vector v = new Vector();
         //Constructor
         public PriorityQueue()
         public int size() {return v.size();}
         public boolean isEmpty() { return (v.size())==0;}
         public void InsertItem(Object e,int k)
              v.insertElementAt(e,k);
              //new code
              //for(int i=0;i<size;i++)
         public Object last()
              return v.lastElement();

    Why not let Java do the work - use a java.util.TreeSet instead of a Vector.
    Make your PQItem implement Comparable, write a compareTo(Object o) method (and an equals method for completeness) and you're golden. Then when you add(pqItem) it goes in the exact spot it belongs.

  • Here's A Question Using A Priority Queue and a DLL

    Ifm trying to make a method that compares two objects that go into a DLL using a priority Queue. SO in other words lets say i have "5" go ino the DLL and then i have "2" that goes in i need to swap the 2 and the 5. And this goes on for any other objects inserted
         private Comparable minPosition() throws EmptyPriorityQueueException {
         if (size() == 0)
         throw new EmptyPriorityQueueException ("No Elements In The Queue");
         else
    now this is what i got so far....but i know that i have toi make to vaiables and compare them? little help please?
    Thanks

    Um, well im using the adapter class, List. so ive gone a bit further, but im not sure on what to do.....
         private Comparable minPosition() throws EmptyPriorityQueueException {
         if (size() == 0)
         throw new EmptyPriorityQueueException ("No Elements In The Queue");
         while (isEmpty()==false)
         r = ((Comparable)elements.first());
         s = ((Comparable)elements.next(elements));
    then i can make r=s and make s serach for the next element,?
    Can the experienced programmers help me out? Doesn't seem to be a tuff question.

  • 7600 QoS Strict-Priority

    Hello,
    I'm testing in a LAB QoS configuration for 7600 (SUP720-3B) with 12.2-18.SXF3 with many diffenents cards.
    Following Cisco documentation, I have two diferent scenarios:
    1. OSM and WAN interfaces supports CBWFQ and LLC and it works fine, as I understand it should work. We could create a priority queue and many standard queues to clasify the traffic and assign differents BW.
    2. LAN interfaces don't support CBWFQ and LLC and we should use the Queue Architecture of the card and WRR and WRED, which are implemented on the ASICs. This is what Cisco calls Hardware-Switched Traffic.
    Here it depends of the card you use what Queue Architecture you could use. But most cards have a Strict-Priority Queue and one or more standard queues.
    My question is regarding about the diferent behavior of the priority queue (LLC) and the Strict-Priority queue in case of congestion on the interface.
    From my testings I got:
    + 1st scenario (Priotity Queue - LLC)
    In case of congestion of the interface, QoS provide to the Priority Queue just the BW configured. If the BW offered in this queue is higher than the BW configured, there're packet drops.
    The rest of the standard queues shares the rest of the BW available on the interface.
    + 2nd scenario (Hardware-Switched Traffic)
    Even with or without congestion, I get almost the same behavior. The router always try to transmit the traffic of the strict-priority queue first. So it doesn't matter how much BW you allocate to the strict-priority queue and the standard queues. The card always try to transmit the traffic of strict-priority queue first.
    Is this the desired behavior or there's something wrong?
    The behavior of the priority queue should be the same in both scenarios?
    I got the following answers from Cisco Web Site which doesn't answer my question completely (See attached file).
    Anyone tried this before???
    Thanks.
    Paco

    Hello Baley,
    Thanks for your reply. I read this link before but it doesn't explain exactly what happens in the scenario described before.
    Few days ago I got an answer from Cisco which confirms what I read from the FAQ: Till Strict-Priority Queue isn't empty, packets on the WRR queues aren't send. This behavior is completely different from the well known LLQ.
    Catalyst 6500/6000 QoS FAQ
    Q. On egress queuing, if the strict priority queue is saturated, will traffic eventually be served in the weighted round-robin (WRR) queues?
    A. No, the WRR queues are not served until the priority queue is completely empty.

  • C2960: ingress priority-queue and CoS/DSCP mapping

    I have read the C2960 manuals for a few times, but I don't seem to find an answer.
    You can enable the priority queue on the ingress interface which has two available input queues for QoS-services.
    What seems to be missing from the manuals is that how can I map/direct the traffic (CoS & DSCP values) to the priority queue?
    I can map traffic to two other WRR (SRR) queues with command: "mls qos srr-queue input cos-map queue queue-id threshold threshold-id cos1...cos8", but there is nothing about the priority queue.
    So is the CoS/DSCP values for the priority queue fixed or how/what traffic is directed to it?
    Thanks,
    Miska

    What seems to be missing from the manuals is that how can I map/direct the traffic (CoS & DSCP values) to the priority queue?
    A: By default, the priority queue is queue 2, and 10 percent of the bandwidth is allocated to it.
    ?For queue-id, the range is 1 to 2.
    Map DSCP or CoS values to an ingress queue and to a threshold ID.
    By default, DSCP values 0-39 and 48-63 are mapped to queue 1 and threshold 1. DSCP values 40-47 are mapped to queue 2 and threshold 1.
    By default, CoS values 0-4, 6, and 7 are mapped to queue 1 and threshold 1. CoS value 5 is mapped to queue 2 and threshold 1.
    ?For queue-id, the range is 1 to 2.
    ?For threshold-id, the range is 1 to 3. The drop-threshold percentage for threshold 3 is predefined. It is set to the queue-full state.
    ?For dscp1...dscp8, enter up to eight values, and separate each value with a space. The range is 0 to 63.
    ?For cos1...cos8, enter up to eight values, and separate each value with a space. The range is 0 to 7.
    What above is saying is queue 2 is priority queue, you can use the CoS/DSCP mapping to queue to move certain CoS?DSCP to either queue 1 or queue 2.
    I can map traffic to two other WRR (SRR) queues with command: "mls qos srr-queue input cos-map queue queue-id threshold threshold-id cos1...cos8", but there is nothing about the priority queue.
    So is the CoS/DSCP values for the priority queue fixed or how/what traffic is directed to it?
    A; See above.
    For more info:
    http://www.cisco.com/univercd/cc/td/doc/product/lan/cat2960/12225see/scg/swqos.htm#wp1161845
    Please rate all posts.

  • 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.

  • Priority queue for voice/audio traffic

    Hi,
    Still in limbo after multiple discussions with our vendors, TAC and in general other engineers, so starting a thread here.  In the process of rolling out enterprise audio, with the intent to prioritize and allocate 25% of link bandwidth for voice class.
    Our config snapshow is as follows -
    policy-map qos-wan-out
     class dscp-voice-lan
      set ip precedence 5
      priority percent 25
    I understand that
    -DURING congestion, this will ensure voice gets a maximum of 25% and is dequeued first due to the priority setting
    -And during NO congestion, the voice traffic will be dequeued before other traffic, but at the same time, can go over 25% as QoS kicks in only during congestion.
    I am seeing some contradictory results in that we are having high packet loss if we exceed 25% even when the link is less than 40% utilized. I doubt the above CE configurations are an issue. But, wanted to run this by this group.
    Alternate theory is that with the above configurations, our traffic is exiting fine - but the service provider who is using priority class queuing within their MPLS network may be capping the bandwidth at 25% at all times (with or without congestion).
    thanks

    Hi Bro
    Maybe the incoming voice packets into your FW isn't marked with ef. For this reason, you don't see anything at all. I hope the QOS isn't tied to a subinterface, as QOS is only supported on the main interface itself. What you're doing here is QoS Configuration based on DSCP. You could refer to this URL for troubleshooting purposes.
    http://www.cisco.com/en/US/products/ps6120/products_configuration_example09186a008080dfa7.shtml#tab4
    Did you marked on the Cisco Catalyst switchports, which ports are ef?

  • 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 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.

  • 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.

  • 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?

Maybe you are looking for

  • My New MAC

    I recently bought a new MAC I-MAC 21.5" Screen. I split the system using Bootcamp in order to play PC games but no games will play because it says I don't have enough video memory. Meanwhile the Besy Buy sales people say I should be good to go. MAC p

  • Items not appearing in cascading dynamic list

    Hi I am having an issue with cascading prompts in Crystal Reports 2008. I have two cascade levels in this report. The report worked fine for a few months until we recently noticed some items were not showing up on the first list. In the database, the

  • Checking for storage location when picking

    Hi all, I'm trying to put some code in the picking requirement to check whether user enters a storage location when they pick via program LV07A111. the storage location is in table LIPS (item table), however, this table is not populated at all.  Do y

  • ARP issues with 3750X & 2960X Stack

    Unable to consistently ping a device from the 3750x that is connected to a vlan on the 2960x stack (po1 between 3750x and 2960x).  ARP statements appear normally in 3750x, where the interface vlan resides.  The device is pingable from through the 375

  • Edge Animate and iBooks Author

    Hello, Let me start by saying that I love Edge Animate! It is easy to learn with plenty of support and examples. However, I am having difficulty publishing my file to iBooks Author. After publishing my animation file, when I drop it into iBooks Autho