Set or map?

I have an array of Strings
I want to remove the duplicate names and order alphabetically into a new array
I think the right way to do this is:
1. add each to a set or map
2. extract the info into an array
3. sort the array
I have never used a set or a map, and dont know which to use or if any of them contain sorting for you
I have read the API but can not seem to find the answer I want

Maps are used when you have key-value pairs, sets are for only values.
Sounds like TreeSet is what you need. The Set classes makes sure you don't get duplicates, and by using the TreeSet it will by default sort the string (where cases matters). If you want to have them sorted where cases doesn't matter, then you can add a custom Comparator class to have them sorted as you want.
If you want to have them in an array, then use
String[] sortedArray = (String[])set.toArray(new String[set.size]);where set is the instance of TreeSet.

Similar Messages

  • Setting servlet mapping?

    a newbie question:
    My servlet are running fine when requested by:
    http://myMachine.com:7777/j2ee/servlet/com.whatever.MyServlet
    However I want it to be reached by:
    http://myMachine.com:7777/servlet/com.whatever.MyServlet
    note the missing "/j2ee". What is the proper way to set this mapping of the servlet directory?
    I assume it might be done in the according web.xml?
    Is it clever to edit web.xml manually? Do I have to use dcmctl udateconfig
    afterwards?
    Any hints are appreciated!

    I see what you mean. WebContent is just a general name. I use maven for building, which uses webapp as a standard.
    As far as having pages in a faces directory, that should be the case. I'm using /faces/* for the servlet mapping in my web.xml. Any requested url with that pattern should map the request to the faces servlet. Whatever page replaces the * would then be located in the root of the webapp directory by the faces servlet.
    My app doesn't seem to be getting that far. The /faces request doesn't seem to be getting to the faces servlet, as there are no initialization lines being dumped to my log file, but when I use *.jsf, it does.

  • How to check the whole values of a set of map exist in the vector of map?

    Hi Friends!
    I have a set of map; map<int, set<int>>myset;
    and a vector of map; map<int,vector<int>>myvec;
    myset contains;
    1=>11  16  30
    3=>2  11
    6=>2
    7=>9  12  16
    8=>9  13  16
    myvec contains;
    1=>11  15  21
    2=>16
    3=>11  16
    4=>2  13
    5=>11  16  30
    6=>9  5  10
    First, the first value of myset(11  16  30) will be checked with all the values of myvec, if the whole value(11  16  30) available at certain value in the myset, then it gives the key of myvec. So, the output for the first value is 5.
    Next, if you consider the value (2  11) in the myset, there are no matching values that contains whole 2  11 in the particular value in myvec. Therefore, what we do is, delete the last value of the current set, that is 11, and now consider 2 as
    the value and find the matching value from myvec. That is (2  13) and the key is 4.
    Like wise when we find the first possible match, then we print the key of myset immediately, there may be some other possible values available in the values of myset.
    I have written two functions that check the particular whole values of the myset matched with a particular values in myvec.
    bool IsValueInVec(int value, const IntVec& v2)
    IntVec::const_iterator itv=find (v2.begin(), v2.end(), value);
    if (itv!=v2.end())
    return true;
    return false;
    bool AreAllValuesInVec(const IntSet& s1, const IntVec& v2)
    for(set<int>::const_iterator sit=s1.begin();sit!=s1.end();++sit)
    if (!IsValueInVec((*sit), v2))
    return false;
    return true;
    Could anyone help me to solve this?

    You have neither a set of map nor a vector of map.  You have two maps.  Each contains keys of type int.  The mapped values of one are of type set<int>.  The mapped values of the other are of type vector<int>.  If
    you don't understand the types of the objects you are using, you will never be able to use them properly.
    Help you solve what?  Do the two functions you wrote perform as desired?  If not, provide a complete description of how what they do differs from what you want.
    Somewhere in code you have not shown, you need to call AreAllValuesInVec for a particular set and vector.  If this function returns false and if the set contains more than one element, you need to delete the last element of the set and try again. 
    If the set contains only a single element, you need to perform some "failure" processing that you have not described.  When the function returns true, you need to print the key of the map element which contains the vector.  What are you
    having trouble with?

  • How to find the most matched values in the set of map?

    Hi friends!
    I have two vectors
    vector<int> V1; vector<int> V2;
    and a map<int, set<int>> M1;
    I want to select common values from both V1 and V2 and check those values with the set in the map M1.
    For example:
    V1 contains;
    2  4  6  8  9
    V2 contains;
    4  5  6  9  10 
    M1 contains;
    1=>1  2  5  9
    2=>4
    3=>5   10
    4=>2  4  8
    5=>4   9
    6=>4   6
    7=>9  12
    When we select the common values of V1 and V2 it is 4, 6, 9.
    And we search for all 4, 6, 9 from the values of M1 which give more appropriate.
    But, no all values in the set of map.
    Then, we delete any value from 4, 6, 9, then remaining values would match any values from the map.
    From the example, if we delete 6, then remaining 4, 9 will match with 5=>4  9, or if we delete 9, then 6=>4   6. Any one of the keys can be selected.
    I know how to select the common values from V1 and V2, but I do not know how to match with the values and select the appropriate key from M1.
    Could anyone help me to solve this?

    This is not the question you asked, except perhaps in the subject. The subject is not the right place to put key features of the question. It is also important to use the body to ask just the question you want
    answered. For example your real question has nothing to do with V1 and V2, just the common vector V (e.g. 4 6 9).
    One way to solve your problem would be to create a new map
    map<int, set<int>> M2;
    with the same keys as M1. Each set of M2 should contain the elements of V that are
    not in the corresponding set of M1.
    Then pick the key of M2 that has the smallest set. If that set is empty, then the whole of V can be used. Otherwise the smallest set tells which elements of V have to be removed, and which is the desired key of M1.
    In your example, key 5 of M2 will contain just 6, so you should remove 6 from V and select key 5.
    Yes fine. I tried the following code and it creates the map M2 (NewMyMap in my code). But how to find the smallest set starting from size 1?
    #include <vector>
    #include <algorithm>
    #include <iostream>
    #include <map>
    #include <set>
    using namespace std;
    typedef vector<int> IntVec;
    typedef set<int> IntSet;
    typedef map<int, IntSet> SetMap;
    bool IsValueNotInSet(int value, IntSet& S);
    SetMap CreatNewSetMap();
    IntVec IVec; //This vector is for selecting certain keys from mySet map.
    IntVec myVec;
    SetMap mySet;
    SetMap NewMyMap;
    int main()
    IVec.push_back(3); IVec.push_back(4); IVec.push_back(5); IVec.push_back(6);
    myVec.push_back(4); myVec.push_back(6); myVec.push_back(9);
    IntSet tempS;
    tempS.insert(1); tempS.insert(2); tempS.insert(5); tempS.insert(9);
    mySet.insert(make_pair(1,tempS));
    tempS.clear();
    tempS.insert(4);
    mySet.insert(make_pair(2,tempS));
    tempS.clear();
    tempS.insert(5); tempS.insert(10);
    mySet.insert(make_pair(3,tempS));
    tempS.clear();
    tempS.insert(2); tempS.insert(4); tempS.insert(8);
    mySet.insert(make_pair(4,tempS));
    tempS.clear();
    tempS.insert(4); tempS.insert(9);
    mySet.insert(make_pair(5,tempS));
    tempS.clear();
    tempS.insert(4); tempS.insert(6);
    mySet.insert(make_pair(6,tempS));
    tempS.clear();
    tempS.insert(9); tempS.insert(12);
    mySet.insert(make_pair(7,tempS));
    cout<<"MYVEC\n";
    cout<<"-------------\n";
    for(IntVec::iterator itv = myVec.begin(); itv != myVec.end(); ++itv)
    cout<<(*itv)<<" ";
    cout<<"\n\n";
    cout<<"\nMYSET\n";
    cout<<"-------------";
    for(map<int,set<int>>::iterator its = mySet.begin(); its != mySet.end(); ++its)
    cout << endl << its->first <<" =>";
    for(IntSet::iterator sit=its->second.begin();sit!=its->second.end();++sit)
    cout<<" "<<(*sit);
    cout<<"\n\n";
    NewMyMap= CreatNewSetMap();
    cout<<"\nNEWMYSET\n";
    cout<<"-------------";
    for(map<int,set<int>>::iterator its1 = NewMyMap.begin(); its1 != NewMyMap.end(); ++its1)
    cout << endl << its1->first <<" =>";
    for(IntSet::iterator sit=its1->second.begin();sit!=its1->second.end();++sit)
    cout<<" "<<(*sit);
    cout<<"\n\n";
    return 0;
    bool IsValueNotInSet(int value, IntSet& S)
    IntSet::iterator it=find (S.begin(), S.end(), value);
    if (it!=S.end())
    return false;
    return true;
    SetMap CreatNewSetMap()
    IntSet TSet;
    for(IntVec::iterator it = IVec.begin(); it != IVec.end(); ++it)
    SetMap::iterator its = mySet.find(*it);
    if (its != mySet.end())
    TSet.clear();
    int key = its->first;
    IntSet& itset = its->second;
    for(IntVec::iterator itv = myVec.begin(); itv != myVec.end(); ++itv)
    if(IsValueNotInSet((*itv), itset))
    TSet.insert(*itv);
    NewMyMap.insert(make_pair(key,TSet));
    return NewMyMap;

  • How to set "Image Map" attribute to "Polygon" via javascript in Illustrator CS5

    Ok, so I have this little script I've written that I want to use to go through a bunch of paths in a document and give each path a url for use in an image map. I want each link to be a Polygon because, well, let's face it, "Rectangle" is useless 99% of the time. Obviously, the way you would do this manually would be to open the Attributes panel and set the Image Map attribute to Polygon and type a URL in the URL field. Fine. Easy enough. However, when scripting the process, it seems one can only set the URL (or the uRL [sic] as documented in the javascript reference) of the PathItem. In other words:
    pathItem.uRL = "http://someurlfor.me";
    Unfortunately, this defaults the "Image Map" attribute to "Rectangle" (which we already know is useless 99% of the time.) SO, anyone out there know how to change that attribute to "Polygon?"
    Btw, I'm on Illustrator CS5 and have been using this reference:
    http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scrip ting/illustrator_scripting_reference_javascript_cs5.pdf
    Thanks,
    -Matt

    We found that with the following setting, the problem is almost solved :
    theme.setQueryWindowMultiplier(1);
    theme.enableAutoWholeImage(true);
    We still have a problem : a portion of the base map appears black most of the time, on Blackberry only (Opera Mini) ... like 1/5 of the map ... the right side ... any idea ?
    Thanks,
    JP

  • ORA-00903: Invalid table name - running Set based mapping

    Hello,
    Using OWB 10.2.04.36 and have created a mapping which reads data from Non-Oracle, ODBC source table, actually a worksheet in an Excel workbook which has been defined/set up using the Heterogeneous Service components.
    I can view the data in the worksheet using the Design Center, Data Object Editor, Data Viewer tab so I know the data is accessible.
    The mapping is performing a Loading Type: INSERT/UPDATE into a View which has an INSTEAD OF INSERT OR UPDATE OR DELETE ON view.
    The mapping validates okay and is deployed successfully.
    Yet when it is run in "Set based" Operating Mode from Control Center Manager the Execution Results show an "ORA-00903: Invalid table name" error is raised.
    You cannot run the mapping in any Row based operating mode as Row based running fails with "ORA:22816: Unsupported feature with RETURNING clause" due to the generated code for the INSERT/UPDATE of the view using a RETURNING clause which is actioned on an INSTEAD OF trigger.
    Looking at the generated package code I can strip out the SELECT statement from the MERGE statement for the alias "MERGE_SUBQUERY" and it runs and displays the expected result, however when the complete MERGE statement is taken and run I get the same ORA-00903 error that was reported in Control Center Manager.
    Any ideas what the problem could be? I have another mapping that reads from the same source Excel workbook/worksheet and INSERT/UPDATE into a table without an INSTEAD OF trigger, this mapping deploys, runs successfully so the issue seems to be with the INSERT/UPDATE into the view. The views are what we require to be populated.
    Thanks.

    Hi,
    But changing V_EMP_DEPT to EMP is not INSERTING/UPDATING to the view V_EMP_DEPT, what you propose is INSERTING/UPDATING into the table EMP. The code was only an example showing that the MERGE does not work when INSERTING/UPDATING into a view based on joining tables. For example say you wanted to INSERT/UPDATE the DNAME of V_EMP_DEPT then the MERGE statement generated by OWB PL/SQL mapping would use the code structure/template:-
    MERGE INTO "V_EMP_DEPT" "V_EMP_DEPT"
       USING (SELECT 5369 "EMPNO",
                     'SMITH' "ENAME",
                     'CLERK' "JOB",
                     7902 "MGR",
                     To_Date('17/12/1980','DD/MM/YYYY') "HIREDATE",
                     800 "SAL",
                     'New Dept Name" "DNAME"
              FROM   Dual,
                     "DEPT" "DEPT"
              WHERE  ("DEPT"."DEPTNO" = 20)) "MERGE_SUBQUERY"
       ON (    "V_EMP_DEPT"."EMPNO" = "MERGE_SUBQUERY"."EMPNO")
       WHEN NOT MATCHED THEN
          INSERT("V_EMP_DEPT"."EMPNO",
                 "V_EMP_DEPT"."ENAME",
                 "V_EMP_DEPT"."JOB",
                 "V_EMP_DEPT"."MGR",
                 "V_EMP_DEPT"."HIREDATE",
                 "V_EMP_DEPT"."SAL",
                 "V_EMP_DEPT"."DNAME")
          VALUES("MERGE_SUBQUERY"."EMPNO",
                 "MERGE_SUBQUERY"."ENAME",
                 "MERGE_SUBQUERY"."JOB",
                 "MERGE_SUBQUERY"."MGR",
                 "MERGE_SUBQUERY"."HIREDATE",
                 "MERGE_SUBQUERY"."SAL",
                 "MERGE_SUBQUERY"."DNAME")
       WHEN MATCHED THEN
          UPDATE
             SET "ENAME" = "MERGE_SUBQUERY"."ENAME",
                 "JOB" = "MERGE_SUBQUERY"."JOB",
                 "MGR" = "MERGE_SUBQUERY"."MGR",
                 "HIREDATE" = "MERGE_SUBQUERY"."HIREDATE",
                 "SAL" = "MERGE_SUBQUERY"."SAL",
                 "DNAME" = "MERGE_SUBQUERY"."DNAME";
    {code}
    This was only an example my target view has a lot more columns being MERGE'd into the view and joined tables.
    Cheers,
    Phil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Setting Google Maps as default Map program

    I am using Torch 9810 Ssw V7.0.0 build 2404 on ATT.  I have installed Google Maps and it seems to be working fine.  Of course the Torch also came with ATT Maps and Blackberry Maps.  How to I set up Google Maps as the default map program so that when I click addresses in the address book, on the web, or in email Google Maps is opened rather than Blackberry Maps.
    I have searched all of the set up options on the Torch, withing Blackberry Maps and within Google Maps but can not find the this possibility.
    Thanks,
    Paul

    You don't, only Apple can do such. However, Google's SDK for their Maps app permits developers of other apps to use Google Maps. Obviously will take time for that to happen.

  • Default setting for mapping execution

    Hi,
    In ODI interfaces I can specify, where the mapping transformation should be transformed (source, statging area or target).
    By default this value is set to "Source".
    If you have interfaces with a lot of mappings on a different system than source it's a lot of work to change all mappings.
    Is there a possibility to change the default value for this parameter?
    Thanks in advance!
    Regards,
    H.

    Hi Rathish,
    I am doing good. How are you and the team?
    Yes, you need to struggle with this. Hopefully will get a workaround/fix in 11g release.
    Thanks,
    G

  • Setting the Maps Access Point

    I just found something quite weird when using Maps on my N82.
    If I set the default access point to a configured WLAN and I set 'Go Online at Startup' to no, or if the WLAN is not available, then when I go and select 'Tools/Go Online' it automatically changes the default access point to the mobile providers on air internet access point.
    So since I have downloaded all the maps for my area I was planning to leave the internet access off mostly, but should I come to turn it on, it will completely ignore the WLAN default setting and go straight to the mobile network therefore costing me money, and not only, it will change the default to this and leave it like that for next time.
    Is there anyway to prevent this behaviour?
    And ideally in general, is there any way to congure a set of access points to try in order e.g. try my home WLAN first, my work WLAN second and then the mobile network third? As far as I am concerned once it has asked me if it can go online I don't want to have to select the access point each time, I would rather it attempts a WLAN if possible and then if not goes mobile all without asking me.
    Any thoughts appreciated.

    I'm kinda in the same situtation, anyway I think it just follows the access points priority on the phone. I was able to use wi-fi in the offline mode (of the mobile)!

  • Setting up MAPI Hotmail on macbook pro

    Trying to set up hotmail account on Macbook. It is asking for exchange servers. Accounts in Outlook through Outlook Connector only shows that it is MAPI, no other info. How do I set up on Macbook?

    Hi,
    I suppose by "Outlook", we are talking about Outlook.com here?
    This forum is for Outlook Client on Windows, if you have come up against any problems with Outlook.com/Hotmail, please refer to the Outlook.com forum:
    http://answers.microsoft.com/en-us/outlook_com
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Regards,
    Melon Chen
    TechNet Community Support

  • Wireless logitech keyboard - unable to set keyboard map in X.

    Hi,
    i have a wireless usb keyboard - logitech k360. When I restart X i always have to manually set keyboard layout using "setxkbmap pl" which is little annoying.
    My laptop keyboard has polish layout set correctly. I tried to modify /etc/X11/xorg.conf.d/keyboard.conf, but cannot find the right options. Here's how it looks now:
    Section "InputClass"
    Identifier "Keyboard Defaults"
    MatchIsKeyboard "yes"
    Option "XkbModel" "logii350"
    Option "XkbLayout" "pl"
    Option "XkbOptions" "terminate:ctrl_alt_bksp"
    EndSection
    I've tried to remove option XkbModel, tried to set it to pc105 and now it is set to logii350 (I've searched through the /usr/share/X11/xkb/rules/ to find my exact keyboard model but it isn't there).
    Funny thing is, that when I type some polish character at my laptop keyboard, suddenly wireless keyboard gets good layout.
    Any thoughts?

    Is this one with the Logitech Unifying Device receiver?
    There are a few threads on this forum about it defaulting to the default QWERTY layout (hell, I have an AZERTY layout - not just as a locale, the key prints are AZERTY). It seems to be some udev bug.

  • WARNING!  OBIEE 11.1.1.6.6 patch set destroys map configurations

    Prior to installing the 7 patches for 11.1.1.6, maps worked fine.
    Immediately after installing the patches, maps were broken.
    Why? Because my customizations to the Configuration settings at http://xyzserver/mapviewer, such as in the <security_config> section or in the Predefined Data Sources section, are GONE, restored back to their original uncustomized configuration. Thank you so very much, Oracle.

    Response on an SR today:
    11.1.1.5.0 BP2 bundle patch bug fixes
    Current ETA has slipped - it is now approx. April 6 for four platforms : Linux64, Windows64, AIX64 & Solaris Sparc 64.
    This will also affect ETA for remaining four platforms .. approx. 3-4 weeks after above 4 patches are released.

  • How to Set up Map MetaData in OBIEE 11g.

    Hi Guys,
    I have one requirement in the spatial data .which am needs to show some states with color on the USA map.
    I am working as developer in OBIEE 11g.
    Dont know about the map Metadata in OBIEE.
    So kindly, share some of your experience and show some demos or steps to implement this requirement.
    my mail id : [email protected] , Bangalore.
    if you share your mail id it will be great helpfull to interact easily.
    Thanks,
    Govardhana

    Hi,
    Can anybody help on this?
    I'm getting errror like "Map metadata has not setup"
    Please help on this...
    Thanks & regards,
    Thiru.K

  • Can I set Google Maps to be the default map app?

    OK, I've had enough.  I thought I could live with the quirks of Apple Maps, but the other day, I was trying to get directions from Reagan airport to my hotel in DC. Although the app correcty located me at the airport, it insisted on starting the directions from *a golf course on the other side of the Potomac*.  Seriously?  This wasn't a tiny mistake.  It couldn't figure out a major airport in a major US city.  That was the last straw.
    I downloaded the Google Map app, and it was wonderful.  Not only did it (of course) give me the correct directions, but it even talked to me (I have an iPhone 4, which Apple has deemed unworthy of turn by turn directions).
    Is there a way to make Google Maps my default Map app? so that when the OS recognizes something as an address it opens that instead of Apple Maps?

    What on earth is wrong with Apple??  The ENTIRE REASON I MADE MY ORIGINAL PURCHASE WAS GOOGLE MAPS. The arrogance of they know better than the folks using their product is astonishing.  I don't care what the articles say, this map debacle is killing potential iPhone sales.  If they will not support MY NEEDS, I'll abandon my investment in applications as the important ones use Google maps and will be worthless anyhow.  Already applications I want demand iOS 6 which I refuse to download.  This phone will become an iPod and I will never again trust apple with my future.  This is not the first time apple has decided for me.  It's going to be the last decision you make for me.  Trust.

  • How can I reset my home setting in maps?

    How can I reset my home location in maps on my iPad

    If your iPad has cellular it can use location services.   Otherwise, the iPad can only locate the approximate address by your IP address (which in my case is in the next state).
    You can edit the bookmarks in Maps to select a new home address and delete the old.
    I believe you can wipe all map contents by turning the switch off:
    Settings
    iCloud
    Storage and backup
    Manage storage
    Show all apps
    Turn off switch, delete, then turn on again.  This will wipe all data from the app.

Maybe you are looking for