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

Similar Messages

  • 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 collection for this purpose

    hai
    i am developing a system which have messaging as the main goal .different clients from remote locations have to send messages(byte array) to an MDB .But my problem is i cant control this messaging system as lot of messages have to be processed by the MDB. So i want a good collection procedure to collect the messages and there by process the messages one by one,.Can any one tell me which collection class is suitable for this or any other ideas. Thanks in advance.

    Decision procedure:
    (a) do you need a separate unique key to access the data? If so, use some form of Map. Otherwise
    (b) do you need uniqueness within the collection? If so, use some form of Set, otherwise some form of List or Queue.
    (c) If you need a Map or Set, do you need ordering? If so use a sorted Map/Set/List (TreeMap/TreeSet), otherwise a hashed Map/Set/(HashMap/HashSet). OR
    (d) if you need a List, do you need random access to inner elements? If so use an ArrayList, otherwise a LinkedList. If you only need access to the front and rear of the list consider a Queue.

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

  • 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

  • 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

  • Best ecommerce plug in for order tracking

    I created a site for a client who is currently only receiving
    orders by email/mail and payment by personal check.
    We want upgrade the site, add a shopping cart with payment
    via Paypal, with USPS shipping costs calculated based on total
    dollar amount...
    i.e.,
    $.01 to $100 = $5
    $101 to $250 = $7
    $251 and up = $10
    with an option to ship 2-day express mail for addtitional $10
    and 5% tax for orders received from one particular state
    Also, we want to be able to show if an item is out of stock
    when added to cart, and allow the customer to check an order status
    by inputting an order #
    What's the best third-party plug in that could handle this?
    Thanks in advance

    oops.. I added some additional info about Apple Loops in the previous post
    All new audio files that has been recorded with Logic allow you to use transpose function
    About Audio streaching method used in Logic search on th Logic manual chapter 23 page 525
    Also search for Time Machine
    it works fine!

  • Collective Planned orders Scheduling for lower level orders with reference to the Superior order

    Hi All,
    Collective planned order scheduling.
    I have been trying to reschedule the superior planned order and i was expecting the lower level planned orders to reschedule based on the superior planned order.
    My problem is
    when i try to reschedule the superior planned order the system is not rescheduling the lower level planned orders.
    For example if i change the basic finish date of superior planned order as 30/09/2014 and reschedule the planned order it is only scheduling the header planned order and the lower level planned order is not scheduling.
    Could some one tell me why this is not happenning at planned order level.
    As the rescheduling of collective order will work at production order level but for some reason it is not happening at planned order level(as there is no option available to do so).
    Please give your thoughts on this asap.
    Mahee.

    Hello Mahee
    Please observe that your system is working as designed. Planned orders are scheduled independently, even when they are part of a network/collective order. Note 152319 explains the planned order scheduling in detail and it provides the following information:
    * No scheduling of overall networks is executed although a directly manufactured component is assigned.
    Note that no scheduling of the overall network is executed for planned orders. For the components requirements dates are determined. In order to cover them, planned orders are created in the next MRP run. Since the requirements are not managed using the exact time, the results of the planned order scheduling and of a scheduling of the overall network of the converted collective order can differ.
    BR
    Caetano

  • Best practice for lazy-loading collection once but making sure it's there?

    I'm confused on the best practice to handle the 'setup' of a form, where I need a remote call to take place just once for the form, but I also need to make use of this collection for a combobox that will change when different rows in the datagrid or clicked. Easier if I just explain...
    You click on a row in a datagrid to edit an object (for this example let's say it's an "Employee")
    The form you go to needs to have a collection of "Department" objects loaded by a remote call. This collection of departments only should happen once, since it's not common for them to change. The collection of departments is used to populate a form combobox.
    You need to figure out which department of the comboBox is the selectedIndex by iterating over the departments and finding the one that matches the employee.department.id
    Individually, I know how I can do each of the above, but due to the asynch nature of Flex, I'm having trouble setting up things. Here are some issues...
    My initial thought was just put the loading of the departments in an init() method on the employeeForm which would load as creationComplete() event on the form. Then, on the grid component page when the event handler for clicking on a row was fired, I call a setup() method on my employeeForm which will figure out which selectedIndex to set on the combobox by looking at the departments.
    The problem is the resultHandler for the departments load might not have returned (so the departments might not be there when 'setUp' is called), yet I can't put my business logic to determine the correct combobox in the departmentResultHandler since that would mean I'd always have to fire the call to the remote server object every time which I don't want.
    I have to be missing a simple best practice? Suggestions welcome.

    Hi there rickcr
    This is pretty rough and you'll need to do some tidying up but have a look below.
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Script>
            <![CDATA[
                import mx.controls.Alert;
                import mx.collections.ArrayCollection;
                private var comboData:ArrayCollection;
                private function setUp():void {
                    if (comboData) {
                        Alert.show('Data Is Present')
                        populateForm()
                    } else {
                        Alert.show('Data Not')
                        getData();
                private function getData():void {
                    comboData = new ArrayCollection();
                    // On the result of this call the setUp again
                private function populateForm():void {
                    // populate your form
            ]]>
        </mx:Script>
        <mx:TabNavigator left="50" right="638" top="50" bottom="413" minWidth="500" minHeight="500">
            <mx:Canvas label="Tab 1" width="100%" height="100%">
            </mx:Canvas>
            <mx:Canvas label="Tab 2" width="100%" height="100%" show="setUp()">
            </mx:Canvas>
        </mx:TabNavigator>
    </mx:Application>
    I think this example is kind of showing what you want.  When you first click tab 2 there is no data.  When you click tab 2 again there is. The data for your combo is going to be stored in comboData.  When the component first gets created the comboData is not instansiated, just decalred.  This allows you to say
    if (comboData)
    This means if the variable has your data in it you can populate the form.  At first it doesn't so on the else condition you can call your data, and then on the result of your data coming back you can say
    comboData = new ArrayCollection(), put the data in it and recall the setUp procedure again.  This time comboData is populayed and exists so it will run the populate form method and you can decide which selected Item to set.
    If this is on a bigger scale you'll want to look into creating a proper manager class to handle this, but this demo simple shows you can test to see if the data is tthere.
    Hope it helps and gives you some ideas.
    Andrew

  • I need an Apple SuperDrive 8X Part No. 661-4279 for my MacBook Pro.  Where is the best place to order one?

    I need an Apple SuperDrive 8X Part No. 661-4279 for my MacBook Pro.  Where is the best place to order one?

    Some sites to check out.
    http://www.powerbookmedic.com/Apple-SuperDrive-DVD-Burner-Drive-8x---Macbook-Pro -p-16916.html
    http://www.macpartsonline.com/661-4279-superdrive-8x-double-layer-pata-15inch-2- 2-2-4-2-6ghz-macbook-pro-a1226.html
    http://www.dvwarehouse.com/661-4279-DVD-R/CD-RW-SuperDrive-8x-Dual-Layer-PATA-fo r-MacBook--MacBook-Pro---NEW-p-37374.html
    http://www.welovemacs.com/6614091r.html

  • How to limit the search scope in single site collection for SP2013?

    On our SP2013 farm, there is one web application and 4 site collections under it. At the beginning I was trying to setup 4 different "Content Sources" but Sharepoint warn me that I can only setup 1 source per web application.
    I don't want user search at site collection A get search result from B, C and D. Also I like to use continuous crawling. What is the best practice to achieve? Thanks.

    Hi,
    Please check this links
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/615edaa8-f522-4496-a57e-9681d83b0ac3/how-to-create-content-type-search-scope-depending-on-each-site-collection?forum=sharepointdevelopmentprevious
    http://sadomovalex.blogspot.in/2013/08/how-to-limit-search-results-to-current.html
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Develop Order Search BAPI for web order

    hi all,
    Develop Order Search BAPI for web order.
    Z_IORDER_ORDER_SEARCH this is the function module i have to use.
    how can i do this as i am new to BAPI.
    thanks in advance.
    shravan

    have you tried this ...BAPI_ALM_ORDER_MAINTAIN

  • Best approach to store collection for html:options

    I am using struts to develop my web application. I am trying to figure out the best way to store a Collection for html:options inside a html:select element.
    My JSP page has a html:select statement which lists all the groups in a system. I have a member variable called getGroupNames() in my ActionForm class. When the JSP page is first requested, I populate the groupNames attribute of ActionForm class with a list of names. The html:options reads the groupNames attribute and lists all the group names.
    The problem: Once the user selects a group name and then submits, if there is any validation problems in other fields in the JSP, I build ActionErrors object and forward the request back to the same JSP. However, now I get an error saying the groupNames is NULL.
    Option1: One way to avoid this error is to AGAIN populate the groupNames list if there is a validation problem.
    Option 2: Another way is to store the list of groupnames in a seperate bean (and NOT as an attrib of the ActionForm) and store it in the REQUEST scope. This way I think the I don't have reload the groupName list in case of a validation failure.
    Could someone please help me in deciding which will be the right approach.
    Thanks

    Hi,
    1,2 billion rows and each row of 50 bytes - approximately 56 GB around. Huge segment. As you stated it's an OLTP database, can you check across what is the percentage or maximum number of queries with developers - important column which they are querying across and application dealt with.
    Based on the input of the above question we can check how best we can partition and columns we are dealing. Perhaps you have stated across historical data. From this kindly verify across what is the % of users check or go-back to historical information - based on that we can estimate the number of partitions we can create on segment and looking forward, you must estimate the % of increase of new/incoming data and day/month wise. so that you might be plan what can we do the old historical data.
    HTH
    Note- Part of Performance dealt with writing efficient tuned queries
    - Pavan Kumar N

  • BEST PRACTICE FOR AN EFFICIENT SEARCH FACILITY

    Good Morning,
    Whilst in Training, our Trainer said that the most efficiency from the Sharpoint Search would be to install the Search Facility on a separate server (hardware).
    Not sure how to have this process done.
    Your advice and recommendation would be greatly appreciated.
    thanks a mil.
    NRH

    Hi,
    You can
    create a dedicated search server that hosts all search components, query and index role, and crawl all on one physical server.
    Here are some article for your reference:
    Best practices for search in SharePoint Server 2010:
    http://technet.microsoft.com/en-us//library/cc850696(v=office.14).aspx
    Estimate performance and capacity requirements for SharePoint Server 2010 Search:
    http://technet.microsoft.com/en-us/library/gg750251(v=office.14).aspx
    Below is a similar post for your reference:
    http://social.technet.microsoft.com/Forums/en-US/be5fcccd-d4a3-449e-a945-542d6d917517/setting-up-dedicated-search-and-crawl-servers?forum=sharepointgeneralprevious
    Best regards
    Wendy Li
    TechNet Community Support

  • Best Practice for Change Maintenance Order Number Range

    Hello
    We have decided that our Maintenance Orders will always start with the year of the open date. Example 201112345155
    Every year we will need to change the number ranges
    What is the best practice to change the order number range? What is the best approach here?
    I have also another question. Why the "Current Number" is not incremental?
    Thanks for the help

    Hi,
    The current number can be explained by use of buffering of the numbers. Buffering is defined via transaction SNRO, the  AUFTRAG object is relevant for orders. When buffering is active, a set of unused numbers are assigned to each application server.
    In your example -  The fiirst 20 numbers were taken from the available number range and assigned to the buffer (possible 10 numbers to each of two servers). As orders are created a number is assigned from the buffer. Once the buffer values are used a further set of numbers are taken from the number range and the current number is increased (by buffer value).
    -Paul

Maybe you are looking for