Best container for random search based on string key

Hi, I have a list of data objects indexed by a univocal string key. I need to perform fast random searches on this list, based on the key value. My current C++ implementation uses an STL map:
map<string, DataObject>
and I search items using operator[].
I was wondering if there is a better choice for the container than STL map, eg., some container which is heavily specialized for this kind of task, or some optimized STL algorithm to perform search instead of map::operator[]. Insertion is not an issue since the list is filled once and for all when my program starts, so I don't need to add items subsequently.
Many thanks

My favourite data structure for a string-keyed associative array is the PATRICIA trie.  I find they perform comparably to hash tables.  You can find a C implementation by me here, and I'm sure there's good C++ implementations.  It sounds like you've already got performance where you want it, but I just figured I'd bring up another option.
Allan wrote:If you can use TR1 features, a std:tr1::hash<string> would be good.
Allan wrote:boost::unordered_map is basically a hash table if I remember correctly.
std::tr1::hash<> is the function object that actually performs hashing; std::tr1::unordered_map<> is a hash map.  By the way, if you can use the tr1 headers instead of boost, you'll cut out a gigantic dependency for your project.

Similar Messages

  • Best collection for ordered search?

    I have a list of objects that need to be in a specific order (e.g. sorted by name). The list does not only contain the names as elements, but specific objects that have a field for the name/id. With a simple ArrayList, this is no problem. However, I also need to search in this (big) list very often for another field (date). The simple search is not very smart (for -loop over all elements until found).
    I found the java.util.TreeMap class and its javadoc tells about what I'm looking for ... i think:
    [This class guarantees that the map will be in ascending key order, sorted according to the natural order for the key's class (see Comparable), or by the comparator provided at creation time, depending on which constructor is used.
    This implementation provides guaranteed log(n) time cost for the containsKey, get, put and remove operations.
    /i]
    So, does this data structure fullfill my 3 needs:
    1) elements need to be sorted
    2) search is quite fast (compared to brainless iteration over all elements)
    3) insertion guarantees the elements to be in sorted order

    You mean to say your list could have three kinds of
    elements: name(String), date or an Object. In that
    case you need to implement comparator for elements in
    a way specific to your needs. I think TreeMap is the
    best fit for your requirement, but I am no expert.
    Just trying to think along with you, I could be as
    wrong as u could be.No, my List contains objects of the same type (class "Item"). Each item object has misc fields: "posId", "incDate" and others. The list is filled so that the objects are ordered by incDate and posId. I sometimes have to search for specific incDate and sometimes for specific posIds, but to make things worse: I don't search for just 1 hit, but for a range of hits (time frame or set of objects with same posIds).
    So, I doubt I can use a Hashtable or a TreeMap, because they are based on unique keys. I fear I have to stick with my plain ArrayList and do stupid for-loop searches to find my ranges - even though the objects are sorted ... ?

  • Best Practice for module components based on API's

    Hi all,
    is there a white paper/other documents which outline best
    practice for using table/module component api's and best
    approaches to get around restrictions?
    I would also appreciate war stories about using this method of
    Forms development bearing in mind i would be using this as the
    foundation of a web deployed based application (intranet first -
    ultimately internet).
    Thanks
    Mark
    null

    You cannot add agents to skills dynamically; however, you can queue the caller into more than one CSQ based on statistics. You would use the Get Reporting Statistics and an If step within the Queued branch of your first Select Resource step. If the condition is met (e.g. Contacts Waiting >= 10) then exectue a second Select Resource step within the queued branch of the first. The contact would then be waiting in both CSQs waiting for an agent.

  • Best practice for adding agents based on queue stats

    I am looking for some guidance (sanity check really) on the best way for to add agent to a CSQ base on call statistics. Scenario: 20 agents logged in and ready. The first 15 agents take all the calls until the contacts waiting reaches 10, then and only then should the other 5 agents start taking calls.
    I appreciate any help or sample scipts on this subject.

    You cannot add agents to skills dynamically; however, you can queue the caller into more than one CSQ based on statistics. You would use the Get Reporting Statistics and an If step within the Queued branch of your first Select Resource step. If the condition is met (e.g. Contacts Waiting >= 10) then exectue a second Select Resource step within the queued branch of the first. The contact would then be waiting in both CSQs waiting for an agent.

  • Best Method For Keyword Search (Full Text Search)

    I have some cataloged columns I am searching for Keywords.
    This table is getting huge over 6.7 million records and it is
    becoming slow. What is the best method to optimize the DB for this
    Search.
    Do I need to create a column that
    will have a keyword associated to a description of each record
    or.... and search this particular column for the Records?. My
    clients records at time are store like "Bolt, Flange" and some are
    stored as "Bolt, Flange 1/4inch....." . Any one with any idea of
    the best methodology of getting this Keyword Search Optimized and
    returning faster query results?
    Thanks

    Consider creating a Verity collection on the appropriate
    columns in your database. The frequency of database update will
    help in determining if this is the appropriate thing to do.

  • Best approach for building dialogs based on Java Beans

    I have a large amount of Java Beans with several properties each. These represent all the "data" in our system. We will now build a new GUI for the system and I intend to reuse the beans as far as possible. My idea is to automatically generate the configuration dialogs for each bean using the java.beans package.
    What is the best approach for achieving this? Should I use PropertyEditors or should I make my own dialog-generator using the Introspetor class or are there any other suitable solutions?
    All suggestions and tips are very welcome.
    Thanks!
    Erik

    Definitely, it is better for you to use JTable. Why not try it?

  • What is the best solution for running windows based programs

    I have one program that I need windows for.  What is the best solution for doing this without painfully slowing down my mac.

    Depends on your needs.
    BootCamp requires reboot and uses all physical resources of the system.  Only OSX *or* Windows can run.  Better for gaming or memory intensive tasks.  BootCampAssistant must set up the boot sector to make it work.  Also BCA required to remove it.
    VM (virtual machine) like Parallels which "hosts" Windows while still running OSX.  You split RAM between the two environments.  VM is just another program so no special boot sector changes needed, but not good for graphics or RAM intensive programs.
    Other recommended alternates to Parallels (paid) are VM Fusion (paid) and VirtualBox (free download from Oracle.com).

  • Best practices for complex recipe-based system?

    Hi Folks,
    I'm at about the intermediate level (working on my CLD), and tasked with re-vamping a tighly-developed control system(which I'm intimately familiar with) into more of a configurable 'recipe'-based system. Basically the current front-end control software does a lot of the work for the end user - it pre-defines flows, assumes certain electrical/plumbing configurations, etc. This is fine for the 'production floor', however the R&D guys would like something a bit more configurable.
    This system comprises of several flow controllers, mostly controlled/monitored via analog I/O (compact FieldPoint). There's some static analog input channels devoted to temp, humidity, etc. There exists the possibility of 1-2 external RS232 metering devices as well.
    Anyway I'm trying to work out the foundation for the UI. In terms of architecture think a que-ed state machine is my best bet due to the number of parallel processes occuring at once (analog acq, multiple serial comm, TDMS, UI, etc).  Basically I'd like the user to be able to add/remove/modify 'steps'. For instance, "Set Flow: controller IDx, 20cfm", or "Time Delay, Static: 10:00", "Time Delay, Psuedo-Static, based on X". 
    I've worked out a configuration UI (utilizing the in-build NI configuration storage VIs) to associate the analog channels to external devices (ie Aout1="Controller1 SP", Ain1="Controller1 FB"). Later I'll populate a ring control, for instance, for the 'add SetFlow step', to list all of the analog OUTs for selection.
    So I guess what I'm looking for is advice on passing all this info around without having to re-hash it all the time to present to the user. Keeping in enum/ring allows for easy user viewing, changing, and block diagram readbility (vs string constants, which are error prone) - is this something that the 'flatten to string' would be helpful for (something I have no experiance using).
    What tips can you provide for moderate-complexity HMI control systems developed strictly in LV? We currently don't have DSC, and I'm a bit closed-minded about using it for this (but perhaps you can convince me otherwise?).
    Thanks for your time,
    Jamie
    Message Edited by 8bitbanger on 04-21-2010 08:10 AM
    v2009 devel. w/RT

    Cool, thanks for the screenshot!
    This request for more customization was anticipated, so I began working things in last year with other minor revs. The first was this 'hardware configuration' utility. Right now I'm only using the MFC Config page for channel scalling/name info. (the production version still relies on 'static' channel associations to control devices). The enum 'card/slot' selector does exactly as you mentioned - it controls a tab value, which loads other pages (with similar info).
    The second 'generator' page is used to populate a list of generators available for the user to select, and works quite well - users can add somewhat custom generators to the list w/out having to specify "custom" every time (and I don't have to rebuild to add such a simple thing).
    You can see the 'Flow Control' and 'Monitor' channel that have not yet been implimented. :-)
    Lastly the mockup is where I want to end up. I *wish* that labview was able to incorperate enum/ring drop-downs within a table cell (without the hacks that I've seen suggested).
    I intended to setup a similar format for the 'steps' - an Action (or noun as you say), Target (ie file path, device name, etc), Value (setpoint, other pertinent data), etc. Do you pass this info around as a cluster in your VI then simply parse out to the UI in the steps listing? My hurdle is how to ellegantly relate, say, a CSV file back to the enums without a lot of hard-coded (constant) strings.
    Cheers,
    Jamie
    ::edit:: *Finally* found the button to insert images... ::edit::
    Message Edited by 8bitbanger on 04-21-2010 10:30 AM
    v2009 devel. w/RT
    Attachments:
    config_UI.JPG ‏52 KB
    generators.JPG ‏39 KB
    mock-up.JPG ‏33 KB

  • Best practices for setting environment based static variables?

    I have a set of static string variables that hold the url location of modules in a project. These locations change depending on whether I'm building for development, staging or production.
    What's the best way to set static variables in this way?

    I don't know if this is best practice, but here's the solution I've come up with.
    The root domain is accessible within the swf via a node on a loaded xml file. So I created a simple method that sets a url variable based on that domain node.
    The domain-based url variable is then used within the static string variables that define the location of the modules.
    Simplified like so:
    var domain:String = xml.node.value;
    static var bucketLocation:String = getLocation()
    static var moduleLocation:String = bucketLocation + "modulename.swf";
    function getLocation():String
         var loc:String
         switch (domain) {
              case stagingUrl:
                  loc = "pathToAmazonStagingBucket";
                   break;
              case productionUrl:
                   loc = "pathToAmazonProductionBucket";
                   break;

  • I need a code for Advanced Search based on my custom multi select listbox and query through programatically (jquery)with out design

    Hi,
    I have a grid and advanced search link buttonand
    search button.
    if i click on Advanced Search link...open a panel with 3 list boxes(multi selection)
    if i select multi selected items in list boxes and click on search-->show the grid with selected items
    getting data from Sql server custom database.
    And the code i wil expect  is 'Programatically using jqury and asp.net code' with out single line of design.
    Could you please help on the above task.

    Hi,
    I have a grid and advanced search link buttonand
    search button.
    if i click on Advanced Search link...open a panel with 3 list boxes(multi selection)
    if i select multi selected items in list boxes and click on search-->show the grid with selected items
    getting data from Sql server custom database.
    And the code i wil expect  is 'Programatically using jqury and asp.net code' with out single line of design.
    Could you please help on the above task.

  • Best practice for deleting data based on mismatch

    I have two tables which share the same key columns (one is an extension table of the other, basically)
    INVPARTINSTOCK_C is current data
    INVPARTINSTOCK_D is a date extension table
    I want to remove all data in D which is not in C
    I can gather a list of mismatched data by using:
    select
    d.Contract,
    d.Part_No,
    d.Location_No,
    d.Lot_Batch_No,
    d.Serial_No,
    d.Eng_Chg_Level
    from invpartinstock_d d
    MINUS
    select
    c.Contract,
    c.Part_No,
    c.Location_No,
    c.Lot_Batch_No,
    c.Serial_No,
    c.Eng_Chg_Level
    from invpartinstock_c c but how do I apply that to a DELETE FROM INVPARTINSTOCK_D WHERE... ?
    Thanks

    1) It depends on, at least, the data volumes we're talking about, but
    DELETE FROM dtable
      WHERE (column_list) IN (your_minus_query)should be functionally correct. Probably more efficient would be
    DELETE FROM invpartinstock_d d
    WHERE NOT EXISTS(
        SELECT 1
          FROM invpartinstock_c c
         WHERE c.contract = d.contract
        )2) Why isn't there a foreign key relationship that prevents this sort of mismatch in the first place?
    Justin

  • Best practices for search service in a sharepont farm

    Hi
    in a sharepoint web application there is many BI dashboards are deployed and also we have plan to
    configure enterprise search  for this application.
    in our sharepoint 2010 farm we have
    2  application server s
    2 WFE servers
    here one application server is running
    c.a + webanalytics service and itself is a domain controller
    second application server is for only running secure store service+ Performance point service only
    1 - here if we  run search server service in second application server can any issues to BI performance and
    2 - its best practice to run Performance point service and search service in one server
    3 -also is it  best practice to run search service in a such a application server where already other services running
    and where we have only one share point web application need to be crawled and indexed with  below crawl schedule.
    here we only run full crawl per week and incremental crawl at midnight daily
    adil

    Hi adil,                      
    Based on your description, you want to know the best practices for search service in a SharePoint farm.
    Different farms have different search topologies, for the best search performance, I recommend that you follow the guidance for small, medium, and large farms.
    The article is about the guidance for different farms. 
    Search service can run with other services in the same server, if condition permits and you want to have better performance for search service and other services including BI performance, you can deploy search service in dedicated server.
    If condition permits, I recommend combining a query component with a front-end Web server to avoid putting crawl components and query components on the same serve.
    In your SharePoint farm, you can deploy the query components in a WFE server and the crawl components in an application server.
    The articles below describe the best practices for enterprise search.
    https://technet.microsoft.com/en-us/library/cc850696(v=office.14).aspx
    https://technet.microsoft.com/en-us/library/cc560988(v=office.14).aspx
    Best regards      
    Sara Fan
    TechNet Community Support

  • KM Search iView for User Search

    Hello,
    I am trying to create a new iView for User Search based on the KM Search iView Template. However, in the properties of the iView (Property Editor) there is no option to assign the ume index (contains users) to the iView. I previewed the iView, entered just a "normal" search term assuming that the iView would at least search for something, but the following error message occured. "TemplateError during search occurred - com.sapportals.wcm.WcmException: Index is corrupted, rollback required;index=ume,location=iwdf0003:39103 (Errorcode 2008)"
    Does anyone know how to solve this problem?
    Thanks a lot,
    Katharina

    Hi Katharina,
    now I understand. The problem is that you can't just use the KM search iView, you need to use a special iView based on com.sap.netweaver.coll.WhoIsWho or com.sap.netweaver.coll.WhoIsWhoNarrow. The configuration to be done (if you named the index for example not "ume") is described <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/05/a62c42de59da2ce10000000a1550b0/content.htm">here</a>.
    You can also find this iView in the com.sap.netweaver.coll.demo.CollaborationDemoRole role by navigating to Collaboration Demo -> People-Centric -> Who's Who.
    The steps on how to create the ume index are described <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/21/ac21410bc3ef23e10000000a155106/content.htm">here</a>.
    Hope this helps,
    Robert

  • Best practices for deploying forms in a 'cluster'?

    Anyone know of any public docs that discuss typical best practices for
    - forms deployment;
    - forms apps management and version control; and/or
    - deploying (and keeping) the .frm/frx in sync when using multiple forms servers in a HA or load balancing envrionment?

    Hi adil,                      
    Based on your description, you want to know the best practices for search service in a SharePoint farm.
    Different farms have different search topologies, for the best search performance, I recommend that you follow the guidance for small, medium, and large farms.
    The article is about the guidance for different farms. 
    Search service can run with other services in the same server, if condition permits and you want to have better performance for search service and other services including BI performance, you can deploy search service in dedicated server.
    If condition permits, I recommend combining a query component with a front-end Web server to avoid putting crawl components and query components on the same serve.
    In your SharePoint farm, you can deploy the query components in a WFE server and the crawl components in an application server.
    The articles below describe the best practices for enterprise search.
    https://technet.microsoft.com/en-us/library/cc850696(v=office.14).aspx
    https://technet.microsoft.com/en-us/library/cc560988(v=office.14).aspx
    Best regards      
    Sara Fan
    TechNet Community Support

  • Custom FM for material search

    Hi expert,
    I am trying to make custom FM for material search based on certain search criteria.
    It give me error like" In unicode programs, the " " character can not appears in names, as it does here in names "LT_MATNRSEL   TYPE TABLE OF BAPIMATRAM".
    Also it giving option for  me as use " type range of" instead of "type table of"
    also when i am making changes saying it is not expected. I am pasting the sample code below.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(IV_MAXROWS) TYPE  BAPIMAXROW DEFAULT 100
    *"     VALUE(IV_MATERIAL_NBR) TYPE  MATNR OPTIONAL
    *"     VALUE(IV_PLANT) TYPE  WERKS_D
    *"     VALUE(IV_MATERIAL_DESC) TYPE  TEXT40 OPTIONAL
    *"  EXPORTING
    *"     VALUE(EV_PLANT) TYPE  WERKS
    *"  TABLES
    *"      RETURN STRUCTURE  BAPIRET2
    *"      RT_MATNRLIST STRUCTURE  BAPIMATLST
       DATA:   lt_matnrsel   TYPE TABLE OF bapimatram,
              ls_matnrsel   TYPE bapimatram,
              lt_matdescsel TYPE TABLE OF  bapimatras,
              ls_matdescsel TYPE bapimatras,
              lt_plantsel   TYPE TABLE OF   bapimatraw,
              ls_plantsel   TYPE bapimatraw,
              lt_return     TYPE TABLE OF bapiret2,
              ls_return     TYPE bapiret2,
              ls_matnrlist  TYPE bapimatlst,
              lt_generaldata TYPE TABLE OF bapimatdoa,
              ls_generaldata TYPE bapimatdoa,
              lt_materialvaluationdata TYPE TABLE OF bapimatdobew,
              ls_materialvaluationdata TYPE bapimatdobew.
    *---  Returning the plant so it can be used as a MBO attribute
            ev_plant = iv_plant.
    *--- fill search ranges value
    *--- Material Description
      IF iv_material_desc IS NOT INITIAL.
        ls_matdescsel-sign        = 'I'.
        ls_matdescsel-option      = 'CP'.
        ls_matdescsel-descr_low   = iv_material_desc.
        APPEND ls_matdescsel TO lt_matdescsel.
      ENDIF.
      IF iv_material_nbr IS NOT INITIAL.
        ls_matnrsel-sign        = 'I'.
        ls_matnrsel-option      = 'EQ'.
        ls_matnrsel-matnr_low   = iv_material_nbr.
        APPEND ls_matnrsel TO lt_matnrsel.
      ENDIF.
    *--- Material Description
      ls_plantsel-sign        = 'I'.
      ls_plantsel-option      = 'EQ'.
      ls_plantsel-plant_low  = iv_plant.
      APPEND ls_plantsel TO lt_plantsel.
    *--- call BAPI
      CALL FUNCTION 'BAPI_MATERIAL_GETLIST'
        EXPORTING
          maxrows              = iv_maxrows
        TABLES
          matnrselection       = lt_matnrsel
          materialshortdescsel = lt_matdescsel
          plantselection       = lt_plantsel
          matnrlist            = lt_matnrlist
          return               = lt_return.
    Thanks And Regards
    Ranjeet Singh

    This post is successful. Only error was in formatting. In my screen there are some dots which was creating problems.
    Thanks for Reply.
    Ranjeet Singh.

Maybe you are looking for