Tree Map maximum value..

I have a TreeMap which contains {1=0.035, 2=0.042, 3=0.031, 4=0.051, 5=0.015}
How can i get the first and second maximum value of this tree...that's mean it should return
{4=0.051, 2=0.042}

You could try:
TreeSet treeSet = new TreeSet(new Comparator()
        public int compare(Object o1, Object o2)
            Comparable value1 = (Comparable)((Map.Entry)o1).getValue();
            Comparable value2 = (Comparable)((Map.Entry)o2).getValue();
            return value1.compareTo(value2);
        public boolean equals(Object obj)
            return false;
treeSet.addAll(treeMap.entrySet());
Map.Entry maxEntry = (Map.Entry)treeSet.last();
treeSet.remove(maxEntry);
Map.Entry secondMaxEntry = (Map.Entry)treeSet.last();
System.out.println(maxEntry);
System.out.println(secondMaxEntry);

Similar Messages

  • How to put into treemap an obj that already  has a tree map?

    i have A Course class that contains a treemap for student.
    now i need another tree map to contain an array of Course.
    Course has it own attributes...
    I tried creating new instance of course
    course= new Course(aRegistrationNo,Add,rmNo.);
    CoursetreeMap.put(aRegistrationNo, Course);
    but this dosent work. Everytime i enter a new Course record, the old student treemap will get deleted also.
    How can i make it so that i can retrive the Course using aRegistrationNo key and the whole student record of the course as well?

    ok..maybe i ask the question differently...
    //initialization
    SortedMap ConCollection = new TreeMap();
    SortedMap MaidContracts = new TreeMap();
    can i do this for the input?
    public void AddAgency(String r){
    reg=r;
    ConCollection.put(reg, MaidContracts);
    //reg is a user input String
    //MaidContracts is another treemap containing a few values
    ============================================================
    is this what i do to get the out put?
    MaidContracts=(SortedMap)ConCollection.get(SelectReg);
    for (Iterator e = MaidContracts.values().iterator(); e.hasNext(); ) {
    cTemp = (Contract) e.next();
    cTemp.getcId();

  • Tree Map Chart

    Hi,
    I am new to Xcelsius and have just started investigating the Tree Map Chart in Xcelsius 2008. Is there a way to permanently show all the values and labels? The Mouse-Over options (under Appearance > Text) works for someone using the Tree Map on a pc, but I have a requirement to include the Tree Map Chart (with associated values and labels) in a printed document.
    Any ideas how I can achieve this?
    Thanks

    Thanks for the suggested solution. The ability to link the label component to a cell will help automate that solution.
    There will be some manual interaction required if the relative size of heatmap changes, since it is not linked dynamically to the label, but that shouldn't be too time consuming.

  • Top 3 maximum values in a table

    Dear Friends,
    I'm just looking for a query to get the top 3 maximum values from a table. For example is a table contains the salary of employees, I would like to get the top 3 maximum salary. Can you please help?
    Thank you in advance.
    Regards,
    Senthil .A. Perumal.

    here is a basic sample:
    select emp_id, sal from employee;
        EMP_ID        SAL
           101       2000
           103       1500
           102       2500
           104       3000
           105       2800
           106       3500
           107       2100
    7 rows selected.
    select emp.emp_id, emp.sal, emp.ranking
    from (select emp_id, sal, rank() over (order by sal desc) ranking
          from   employee) emp
    where ranking <= 3;
        EMP_ID        SAL    RANKING
           106       3500          1
           104       3000          2
           105       2800          3hope this helps.

  • Get maximum value in a field using SQL query

    Hi,
    I want to retrieve the row containing the maximum value for a particular field.
    select max(fieldname) from tablename
    How do I do this using database connectivity toolkit.
    Shiva

    Hello,
    I figured out the answer. It was sql syntax.
    Thanks for coming in here to help.
    I created another post earlier because I had a little different question that pertained to fetch.vi.  How do you get an array out from fetch.vi without creating error. I also made type an array also but it does not allow an array.
    Thanks for your help.
    By the way, how do I as the original poster get rid of a whole thread I created, especially if its a duplicate.

  • How to find out the maximum value of one array

    hi all..
    I have one array that consists of some elements
    so I want the maximum value of the list ...
    if anyone knows this please help me..
    thanks..

    >
    If your array is already sorted, you can do a binary
    search.
    I think there are already methods to do that in
    java.util.Arrays. (?)
    If not, it's not hard to find an example on the net.
    A binary search will be more efficient.1. If your array is already sorted, you do not need a binary search. Either check the value of arr[0] or arr[arr.length - 1] depending on the direction of sorting.
    2. If your array is not sorted, try this:
    int maxValue = arr[0];
    for(int index = 1; index < arr.length; index++)
      if(arr[index] > maxValue)
        maxValue = arr[index];
    }

  • How to find out the maximum value in a Query

    Dear all,
    Im creating a Query on 0SD_C03 where i have to disply Maximum value of a material..
    EX:
    MATERIAL BILLED VALUE
    x                   1000
    y                   3000
    z                   2500
    in a analyser i have to display only Y and 3000
    We are using BW 7.0 version
    Can any one help me out in this
    Thxs in Advance
    Venu

    Hi Venu,
    You may wish to refer the link below:
    http://help.sap.com/saphelp_nw04/helpdata/en/17/82853c2dc5c505e10000000a11405a/content.htm
    Assign points if this is helpful.
    Regards,
    Anil

  • How to find out the maximum value in a Query within single material

    Dear all,
    Im creating a Query on 0SD_C03 where i have to disply Maximum value of a material which is having more that one transaction..
    EX:
    MATERIAL BILLED VALUE
    x with BILLED VALUE 100
    x with BILLED VALUE120
    y with BILLED VALUE 50
    y with  BILLED VALUE 80
    z with BILLED VALUE 50
    z with BILLED VALUE 60
    in a analyser i have to display X with billed value 120 that is max in X material and
    Y with billed value 80 that is max in Y material and
    Z with billed value 60 that is max in Z material
    In a query all the values are summing up. I.e for X its 220 and Y its 130 and Z its110 but we dont want to get total sum value we want individual values and the maximim of those values.......... 
    We are using BW 7.0 version
    Can any one help me out in this
    Thxs in Advance
    Venu

    Venu,
    In your query try creating a formula, with the value of each record as the key figure in the formula.
    In the aggregation tab select maximum in the exception aggregation dropdown and then select material as the reference characteristic
    then when you include material in the rows it will only display the maximum value.
    cheers
    mark

  • How to find out the maximum value

    Dear all,
    i have one query where in i have to calculate Excise Duty based on the  maximum  sales qantity of all materials with the corresponding sales value... i mean i wil get the maximum value of a individual material no matter how many sales has done.i wil pick up the maximum sales qty and the correspondig sales value....
    This im able to solve by taking the condition as TOP 1..
    Now my question is if the same material qty is sold with differnt value then i have to pick up the  Max value and as usual the sales qty..... plz help me out
    Material              Sales Qty              sales value
           3000                10 kl                   1000INR
           3200                15 kl                   1100 INR
           4000                20 kl                   1000INR
    in this case my query is picking up the max qty of  20 and the value 1000 INR as i had taken TOP 1 on Sales qty ....
    <b>
    But In the below example  for the same material i have to pick up the 3 rd row  where the sales value is maximum and the corresponding sales qty 10 kl</b>
    EX   Material        Sales Qty              sales value
           3000                10 kl                   1000INR
           3000                10 kl                   1100 INR
           3000                10 kl                   1500INR

    Hi,
    U can use the restrict option fo the Material characteristics  for sales value just drag and drop on columns >right click Properties> U have the option Calculated Result as Summation, Maximum, Minimum etc..just choose Maximum for ur case.

  • Mapping input values for a web service connection to a range of cells

    I've created a web service connection in Xcelsius data manager. My web service requires an array of integer as input parameter. How do I map input values for a web service connection to read from a range of cells in the spreadsheet, e.g. $A$2:$A$20, in similar way of mapping output values to write to a range of cells in the spreadsheet?
    For output values of the web service, I can specify to map the output values to write to a range of cells. However, it doesn't seem to work for reading the input values.
    I can map input values for each node to a single cell, e.g. $A$2, in the spreadsheet. However, when I set the "Read From" field to a range of cells, e.g. $A$2:$A$20, it only reads in the first value in the range.
    Is there any way that we can do this mapping for input values as we do for output values?
    Your assistance is very much appreciated.
    Regards,
    Van

    Van,
    There is a workaround for that...
    Example:
    My Webservice accepts input data range in a specific format with " :" symbol, i.e. 072008:082008
    Now what i do is
    A1 = 072008
    A2 = 082008
    A3 = CONCATENATE(A1,":",A2)
    so A3 = 072008:082008
    Now i map the input value in web service to cell A3
    P.S have 2 input box components and map it to cells A1 and A2, i.e you are giving users an  option to enter the range of values...then web service will capture the range and refreshes data with the range of values user entered.
    hope this helps..
    -Anil

  • Cap on Maximum value of payment in single payment run (F110)

    Hi All,
    we have a requirement to put a cap on maximum value of payment in payment run in F110. Kindly suggest me how we can do this.Is there any sta
    Thanks & Regards
    Deepak Garg

    Hi Deepak,
    Please find below the answers to your queries.
    1.Let us suppose that you have already posted a document with a payment method C( say for 255000 Euros). Later you go configure your company code specific payment method C and stipulate a limit of 250000 Euros as maximum amount . The maximum amount stipulation does not bind this invoice item which was created earlier. This item can be paid via payment method C. The maximum limit applies to documents posted after completion of your configuration.
    2.In standard SAP payment amount limit is per payment method level, and cannot be set at payment run level.
    The alternative option would be adding a "user exit" with the help of ABAP Team for this specific purpose. The second alternative, though not practicable, would be reviewing the proposal run and making the necessary changes to restrict the total payment amount.
    Warm regards,
    Murukan Arunachalam

  • Tree Map Issue in Dashboard for IPAD

    Hi Experts,
    i have used Tree Map in My Xcelsius dashboard but tree map chart is not supported in IPAD.Can any one suggest me the chart which will fulls fills the tree map or if any workaround for that.
    Using Dashboard Version:Dashboard 4.1
    I really would appreciate your help.
    Thanks,
    Prasad

    Hi Prasad,
    We dont really have any chart similar to Tree Map.
    But if you could help us understand what is the data that you are trying to display then maybe we could think of something.

  • Maximum value of a Internal table field

    Hi ,
    I have been struck in 1 place.
    I am getting Payment term from Zterm from VBRK table .
    Now I have to fo to table T052 and according to ZTerm - I get the 3 different value - ZTAG1 , ZTAG2 ,ZTAG3.
    Out of these i need to fetch the maximum calue out of ZTAG1, ZTAG2 ,ZTAG3.
    i DONT WANT TO CASE STATEMENT.
    pLS HELP

    If you're lucky and on a new version (I think you'd need at least 7.0.2) you could use the predefined ABAP function [nmax|http://help.sap.com/abapdocu_70/en/ABENNMAX_NMIN_FUNCTIONS.htm]:
    max_tag = nmax( value1 = t052-ztag1 value2 = t052-ztag2 value3 = t052-ztag3 ).
    On lower releases you're out of luck and you have to code it yourself. Should be obvious how to code it, but let me be explicit:
    max_tag = t052-ztag1.
    if t052-ztag3 is not initial.
      max_tag = t052-ztag3.
    elseif t052-ztag2 is not initial.
      max_tag = t052-ztag2.
    endif.
    Now, why did I post such a trivial solution? Because the previous poster gave one, but as you can see one can make it shorter and more legible. My solution is based on the fact that the number of days from baseline date must be in ascending order, i.e. ztag1 < ztag2 < ztag3 or a value can be 0 and then all following values have to be zero (if you try it in customizing you'll see that other combinations are not possible).
    Obviously neither my nor the previous solution works in general to determine the maximum value of three numbers (though of course that's also trivial to implement and I think the disadvantage of the previously posted solution is that it's not necessarily immediately obvious).
    Cheers, harald

  • How to map column value (in table cell)

    Hi,
    My table, say product, has 'status' field (varchar(1))
    status = 0 -- unavailable product
    status = 1 -- avaialble product
    I want to map this value into readable 'available/unavailable'
    (a combo box cell editor) when I manipulate table cell (insert/search/modify)
    and status field correctly mapped into '0', '1'.
    Thanks,
    Tuan

    repost

  • Exchange Rate is picking the Maximum value, instead of valid from

    Every first day of month we enter exchange rates for foreign currencies.
    but when we make  Purchase Order or any other payments in foreign currency, system is picking the maximum value, but not the value from Validity date.

    Hello,
    Thanks for your immediate response.
    But my Question is for e.g.
    on 01.01.2010  entered Exchange rate is 1 euro = 5.6954 SAR
    on 01.02.2010  entered Exchange rate is 1 euro = 4.9653 SAR
    if am posting document on 16.02.2010 it should pick the second value i.e., 1 euro = 4.9653 SAR, but system is picking the maximum value.

Maybe you are looking for

  • Powermac G5 dual 2.5 won't switch on

    my powermac G5 dual 2.5 osx 10.4.11 it was working fine ,I left it switched on while i went for food came back to it a few hours later and it had switched off and it will not power up. i have tried new mains lead and alternative power socket but alas

  • How to add the data dynamically in data grid

    Hi, I got a stuck up in using JSF as I am trying to retrieve a value of a text box on clicking a button in the datagrid. Please suggest me a solution for his

  • Duplicate Profiles and Syncing Issues

    My duplicate accounts are: # [email protected] # [email protected] # [email protected] I have a problem that has plagued me for several years now and keeps getting worse. I have three profiles setup because of various log-in issues over the years. I

  • Aperture Library movement

    I need to move my Aperture library to another internal drive due to space considerations. Looked over this forum. I did move the library and redirect Aperture, rebooted, but I see that all the raw files of "projects" are still in my Pictures part of

  • Debit note - Subsequent debit

    Dear all 1.what is the difference between debit note and subsequent debit 2.credit note and subsequent credit 3.credit memo Please guide me with a simple example