List of Map Filter Algorithm

I need to make a search on a List of HashMap object. The searchkey can be more than one. I need some advice on how to go about it. I really think there is a better way than doing an iteration with the list.

How does the list fit into all of this again? It
might be good if you posted formatted
code that had the basic outline of your data
structure. I mean yes I see you have a map above but
you mentioned a List as well and I don't know what
you have going on here exactly.
I'll post some code to enlighten you.
List l=new ArrayList();
Map el;
for (int i=0;i<10;i++) {
  el=new HashMap();
  el.put("Name", "SomeName"+i+3);
  el.put("Address", "SomeAddress"+i+1);
  el.put("Id", "SomeId"+i+2);
  l.add(el);
Do you know what a binary search is?yes. I know what a binary search is.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • "Economizing" in a list of maps with identical keys (like a database table)

    Hi there!:
    I've been checking this forum for information about something like what I state in the title of this message, but haven't found such a specific case. I'm commenting my doubt below.
    I'm working with a list of maps whose keys are exactly the same in all them (they're of type String). Indeed it could be considered an extrapolation of a database table: The list contains maps which act as rows, and every map contains keys and values which represent column names and values.
    However, this means to repeat the same key values on every map and this spends memory. Right, maybe it's not such a big spent, but since the list can contains thousands of maps, I think that it would be better to choose a more "economical" way to achieve the same result.
    I had thought about building a class which stored everything as a list of lists and, internally, it mapped that String keys with the corresponding Integer indexes of every list. But then I realized that maybe I was re-inventing the wheel, because it's very probable that someone has already made that. Maybe is there a class on the Core API which allows that?
    Thank you very much for your help.

    Well, after re-reading the Java tutorial which is located in the Sun website I've came to a conclusion which I should have before, when I thought about using StringBuffers as keys of the maps instead of Strings.
    I'm so used to build Strings using literals instead of the "new String ()" constructor (just as everyone) that I had forgotten that, as it happens with any kind of object but not the primary data types, Strings are not passed to the methods by value, but by reference. The fact of them being immutable made me think that they were passed by value.
    Apart of that, my problem also was that using literals I was creating different String objects every time, despite the fact that they were equal about their content (making 400 different keys called "name" for example)
    In other words, I was doing something like this:
    // It makes a list of maps which will contain maps of boy's personal data (as if they were "rows" in a table).
    List <Map <String, Object>> listData = new ArrayList <Map <String, Object>> (listBoy.size ());
    // It loops over a list of Boy objects, obtained using EJB.
    for (Boy boy : listBoy) {
         // It makes a new map containing only the information which I'm interested on from the Boy object.
         Map <String, Object> map = new HashMap <String, Object> (2);
         map.put ("name", boy.getName ());
         map.put ("surname", boy.getSurname ());
         // It adds the map to the list of data.
         listData.add (map);
    }Well, the "problem" here (being too demanding, but I'm :P ) is that I was adding all the time new Strings objects as keys in every map. The key "name" in the first map was different from "name" in the second one and so on.
    I guess that my knowledge got messed at certain point and thought that it was impossible to use exactly the same String object in different maps (the reference, not the same value!). Thus, my idea of using StringBuffers instead.
    But thinking about it carefully, Why not to do this?:
    List <Map <String, Object>> listData = new ArrayList <Map <String, Object>> (listBoy.size ());
    // It makes the necessary String keys previously, instead of using literals on every loop later.
    String name = "name";
    String surname = "surname";
    for (Boy boy : listBoy) {
         // It uses references (pointers) to the same String keys, instead of new ones every time.
         Map <String, Object> map = new HashMap <String, Object> (2);
         map.put (name, boy.getName ());
         map.put (surname, boy.getSurname ());
         listData.add (map);
    }Unfortunately, the "hasCode" method on String is overloaded and instead of returning the typical hash code based on the single ID of the object in memory, it returns one based on its content. That way I can't make sure that the "name" key in one map refers to the same object in memory than another one. I know, I know. The common sense and the Java documentation confirm that, but had loved having an empiric way to demonstrate it.
    I guess that using "javap" and disassembling the generated bytecode is the only way to make sure that it's that way.
    I believe that it's solved now :) (if no one tells me the contrary). I still am mad at myself for thinking that Strings were passed by value. Thinking about it now it had no sense!
    dannyyates: It's curious because re-reading every answer I think that you maybe were pointing to this solution already. But the sentence "you put the +same+ string" was a little ambiguous for me and thought that you meant putting the same String as "putting the same text" (which I already was doing), not the same object reference (in other words, using a common variable). I wish we could have continued discussing that in depth. Thanks a lot for your help anyway :) .

  • Custom drop down list for the filter for BEX report

    Hi, all:
    I am writing a query for a BEX report that prompts the user to enter a value for a field "GL account".  I would like to have the user select from a limited number of GL options rather than have the whole Chart of accounts show up. Is there a way to make a "custom" drop down list for the filter?
    Thanks!
    Jenny

    You need to make your GL account info object as an authorization object. And in the info object ,for BEx you need to select the option "only authorized values".
    Create an analyis authorization on gl account and assign the restricted set of GL accounts to the user. Asign this analysis authorization to the user.In the query restrict this infoobject with an authorization variable. This would solve your purpose.user would be able to see only a selected set of GL accounts for which he is authorized.

  • Possible to use list filters to filter library?

    Hi-
    We have a library of documents, and want to add XLS to how it displays for end users. However, doing so means we can't use column header filtering.
    so, we tried to use List filters (as ugly as they are), but they will not allow us to  connect to the web part showing the documents.
    Has anyone been able to use OOB functionality to add one web part (EG, sharepoint list filters) to filter a document library display?
    thanks.
    Barbara Selden director, Business Readiness 110 Consulting

    Hi Barbara,
    As I understand, you want to use OOB functionality to add one web part (EG, sharepoint list filters) to filter a document library display.
    Could you please provide the screenshot of the SharePoint list filter web part configuration?
    You should make sure the SharePoint list filter web part and document library in the same page. When they are in the same page, you could build the connection between them.
    Then you could edit the web part to choose the document library in the list section, view and value field. Then create the connection to the document library by clicking connection. You could click the drop-down arrow in the upper-right corner of the SharePoint
    list filter Web Part, click Connections, click Get Filter Values From, and then select the custom list.
    Then you could enable Server Rendering in the document library web part. You could edit the document library-> Miscellaneous > Enable Server Rendering.
    After all you could filter the document library.
    The article below is about how to connect a SharePoint List Filter Web Part to a Data View Web Part.
    https://support.office.com/en-us/article/Connect-a-Filter-Web-Part-to-a-Data-View-Web-Part-bc10362e-afaa-42dc-b09e-ba8b1b83bb3c?CTT=5&origin=HA010033786&CorrelationId=6ed6821e-b67e-4adf-bd83-6ccc18441ec0&ui=en-US&rs=en-US&ad=US#bms5
    Best regards,
    Sara Fan
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Animated bump map filter, how to ?

    Hi(Bonjour)!
    I want to animate on a path an small oval shape and use this shape as a bump map in a bump map filter ( or displace filter). The goal is to "push out" a small portion of my movie like if someone is pushing beneath the screen.
    The result doesn't animate and despite many tweakings, the bumped portion is a large oval instead of finger's tip.
    Motion manual says :
    +"Bump Map+
    +This filter uses a source object to define a bump pattern which can be used to deform+
    +an object, with parameters to control the amount of distortion. You can use any image,+
    +movie, or shape as the source object."+
    How to achieve this effect?
    Thank you.
    Michel Boissonneault

    Yes it seems to blow up anything in the image well to fill the screen.
    Have you tried bulge?
    Peter

  • Premiere can't open the Displacement Map filter saved in AE as a PP file. Says DM filter is missing.

    Premiere can't open the Displacement Map filter saved in AE as a PP file. Says DM filter is missing. Also get a message that the format of the AE file does not match the sequence. Asks me to keep existing settings or match sequence - neither way works. Tried to dynamic link as well - no luck. I'm a noob, so could be something real simple.
    Thanks

    Effects or any other features like e.g. text or shape layer, which do not exist in PrPro, can't be translated when you export your AE project as PrPro project. Similar things happen when you replace a clip (or a group of clips) in PrPro timeline with dynamically linked AE composition: titles, quite a few effects and transitions are not translated (at least properly).
    However, dynamically linked AE composition is treated as a composite in PrPro. Hence, there should be no issue seeing the result of applying any effect inside dynamically linked composition in PrPro timeline. If you have some difficulties with it, please provide a detailed explanation of what you want to achieve and what you're doing exactly.

  • Sorting in List Hash Map

    Hi All ,
    I i have the data in below format:
    Name     Age     Skill     Company
    Vass     21     Java     Zylog
    Samy     24     PB     HP
    Lee     18     ADF     CTS
    Reng     16     Java     Info
    I converted this data into java collections List<Hash Map> like this.
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    public class HashMapDemo {
        public static void main(String[] args) {
            // Create a hash map
            List<HashMap> list = new ArrayList<HashMap>();
            HashMap hm = new HashMap();
            hm.put("Name", new String("Vass"));
            hm.put("Age", new Integer(21));
            hm.put("Company", new String("Zylog"));
            hm.put("skill", new String("Java"));
            list.add(hm);
            HashMap hm1 = new HashMap();
            hm1.put("Name", new String("Samy"));
            hm1.put("Age", new Integer(24));
            hm1.put("Company", new String("HP"));
            hm1.put("skill", new String("PB"));
            list.add(hm1);
            HashMap hm2 = new HashMap();
            hm2.put("Name", new String("Lee"));
            hm2.put("Age", new Integer(18));
            hm2.put("Company", new String("CTS"));
            hm2.put("skill", new String("ADF"));
            list.add(hm2);
            HashMap hm3 = new HashMap();
            hm3.put("Name", new String("Reng"));
            hm3.put("Age", new Integer(16));
            hm3.put("Company", new String("Info"));
            hm3.put("skill", new String("Java"));
            list.add(hm3);
            Iterator i = list.iterator();
            while (i.hasNext()) {
                System.out.println(i.next());
    } As per data (table format) i want to sort the data in Column level
    how can i to achieve ?.
    List<HashMap> is type of collection is help to me?
    Any idea?
    Thanks,
    Vass Lee

    Check out Comparator, and use Google to find examples on how to use it.
    http://download.oracle.com/javase/6/docs/api/java/util/Comparator.html
    Still sorting a collection of hashmaps is a bit odd design though. I think you want to create a simple class with properties in stead of a HashMap, then implement Comparable on that class.

  • Normal Map Filter Error

    when i want to make normal map for some pic,photoshop stops working and close the program.i use nvidia normal map filter.......but i try to make it with other script(CombineNormal),but this scipt stops working too....what the problem is it and how to fix it?? my OS is win 8.1 pro,PS version is cc 2014.2
    event viewer log
    Faulting application name: Photoshop.exe, version: 15.2.1.257, time stamp: 0x543dbc5e
    Faulting module name: Photoshop.exe, version: 15.2.1.257, time stamp: 0x543dbc5e
    Exception code: 0xc0000005
    Fault offset: 0x0000000000020a30
    Faulting process id: 0x12fc
    Faulting application start time: 0x01d0024a3f771388
    Faulting application path: C:\Program Files\Adobe\Adobe Photoshop CC 2014\Photoshop.exe
    Faulting module path: C:\Program Files\Adobe\Adobe Photoshop CC 2014\Photoshop.exe
    Report Id: 412a6287-6e3f-11e4-826c-001e8ca89e26
    Faulting package full name:
    Faulting package-relative application ID:
    this one for 2nd script
    Faulting application name: CombineNormals_x64.exe, version: 1.0.3.0, time stamp: 0x5327616a
    Faulting module name: CombineNormal_x64.dll, version: 0.0.0.0, time stamp: 0x5309f61a
    Exception code: 0xc000001d
    Fault offset: 0x0000000000002778
    Faulting process id: 0xf88
    Faulting application start time: 0x01d0024bf7de85b4
    Faulting application path: C:\Program Files\Adobe\Adobe Photoshop CC 2014\Presets\Scripts\CombineNormals_x64.exe
    Faulting module path: C:\Program Files\Adobe\Adobe Photoshop CC 2014\Presets\Scripts\CombineNormal_x64.dll
    Report Id: 37f9eff3-6e3f-11e4-826c-001e8ca89e26
    Faulting package full name:
    Faulting package-relative application ID:
    Application: CombineNormals_x64.exe
    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.Runtime.InteropServices.SEHException
    Stack:
    at CombineNormals.NormalControl.CombineCropped()
    at CombineNormals.NormalControl.CombineCropped()
    at CombineNormals.NormalControl.Initialize(CombineNormals.View, System.String ByRef, Single[] ByRef)
    at CombineNormals.SplashScreen..ctor(CombineNormals.Interfaces.INormalControl, CombineNormals.View, System.String ByRef, Single[] ByRef, CombineNormals.ParentWndWrapper)
    at CombineNormals.View..ctor(CombineNormals.Interfaces.INormalControl, CombineNormals.ParentWndWrapper)
    at CombineNormals.Program.Main()

    I'm actually talking about something more along the lines of the NVidia Normal map filter... as found here:
    http://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop
    I want to create animated normal texture maps for use in 3D software...

  • List Column Dropdown Filter Missing Choices

    I have a list with 1768 items. When i try to use the list column dropdown filter menu it does not give any options.
    This is what I see when I click on the Client Name list column
    When i click on another list column I get this.
    I there anything I can do to get the options in Client Name as Status or any of the other list columns?
    Thanks
    James T.F

    Hi James,
    Based on your description, my understanding is that you want to show the values in Client Name column for filtering.
    When a SharePoint List gets to a certain size, around 500 items, some fields will no longer display a proper drop down for filter choices.
    Instead, it will display “Show Filter Choices”.  Microsoft did this to prevent performance problems by showing more than 500 options to choose from.
    As a workaround, I recommend to create views to filter the list instead.
    Best Regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Iterate through a list containing Map items using struts

    Hi friends,
    I have a small problem. I want to iterate through a list of items, using struts.
    The list actually contains map structres for example:
    list(0)
         map(..key..value..)
         map(..key..value..)
         map(..key..value..)
    list(1)
         map(..key..value..)
         map(..key..value..)
         map(..key..value..)
    list(2)
         map(..key..value..)
         map(..key..value..)
         map(..key..value..)can I use <logic:iterate/> for this? if yes how? Because I have used this tag for list containing bean objects not Map.
    Any suggestions are much appreciated.
    Thanks,
    Vishal

    Normally, each object exposed by the iterate tag is an element of the underlying collection you are iterating over. However, if you iterate over a Map, the exposed object is of type Map.Entry that has two properties:
    key - The key under which this item is stored in the underlying Map.
    value - The value that corresponds to this key.
    So, if you wish to iterate over the values of a Hashtable, you would implement code like the following:
    <logic:iterate id="element" name="myhashtable">
    Next element is <bean:write name="element" property="value"/>
    </logic:iterate>
    Best Regards
    Maruthi

  • Iteration through a list of map entries

    hi,
    I am facing a situation in which i have to write a rule to iterate through a list of map entries within a map and again iterate for a given attribute through a map of attributes within the selected map entry.
    Can anyone throw light on any function or expression in the XPRESS language in the Identity Manager to accomplish this.
    thanx in advance,
    yashuwyah

    HI,
    I cant help you out with full code at this point. But do make use of the following to determine the equivalency between GenericObject and HashMap as shown below.
    Basic Operations
    � map.keySet() == genObj[*].name
    � map.entrySet() == genObj[*]
    � map.get(attribute) == genObj.attribute
    � map.get(attribute1).get(attribute2).get(employeeNumber) ==
    genObj. attribute1. attribute2.employeeNumber� if attribute1 indexes a list object in the preceding example ==
    genObj. attribute1[attribute2].employeeNumber� Searches
    � find the object with the attribute fullname = �John Smith� ==
    genObj[fullname=John Smith]� get John Smith�s employeeNumber == genObj[fullname=John
    Smith].employeeNumber� List Operations
    � get the names of all permanent employees ==
    genObj[employeeType=permanent].nameFor your requirements, I figure that you can iterate through the list in the beginning and assign the initial result to a <defvar>. Then use the reference of this to determine the required attributes next.
    IC.

  • Users are unable to expand a list when a filter is applied in SharePoint 2010 site

    There are set of users facing issues while filtering the contents in the SP2010 site since the migration to SharePoint 2010. It is no longer possible to expand a list when a filter is applied.
    When open a fresh browser the filter does work, but if we perform an edit or save in the list, the filtering option disappears for the entire site.
    Then we need to forcefully close all the active browsers and start a new browser to see the list. Have checked with different browsers and different machines ended up with the same issue. Could you please suggest a workaround for the problem? Thank you.

    Check if On alternate access mappings might be causing this issue

  • Normal Map filter for After Effects? :D

    Is there a filter or plug for After Effects that allows you to convert a sequence of heightmaps into a sequence of normal maps?
    I tried using the NVidia filter in Photoshop as a batch process but it seems to choose its own settings for the NVidia filter...
    Maybe someone has another suggestion?
    Thanks!

    I'm actually talking about something more along the lines of the NVidia Normal map filter... as found here:
    http://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop
    I want to create animated normal texture maps for use in 3D software...

  • How to implement State of charge kalman filter algorithm in C code

    hi,
    I am going to implement kamlan filter algorithm in C code. Is anyone here did this before. Please share your ideas and tell me how i can implement this. Give me some ideas. It would be highly apreciate. thanks in advance
    here i attached the kalman filter algorithm file.
    regards,
    usman
    Attachments:
    1.docx ‏74 KB

    Hi,
    did you already have a look at some implementations of the Kalman filter ? For example, that one : 
    Kalman filter c code implementation. How to tune required variables?
    http://forums.udacity.com/questions/1021647/kalman-filter-c-code-implementation-how-to-tune-required...
    or that one :
    http://alumni.media.mit.edu/~wad/mas864/psrc/kalman.c.txt
    Hope it helps!
    Aurelie

  • Problem with list and map in GWT

    I have a problem with map and list in GWT. I need to put a map in to a list but GWT does not support ArrayList and HashMap since they are not serialized types.
    Exactly I want to create following list with out using ArrayList and HashMap
    ArrayList<HashMap<String, Object>> map = new ArrayList<HashMap<String,Object>>(); Thank you for new ideas,
    Regards

    If try to use ArrayList then I receive following exception when I make a rpc call.
    Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.ArrayList' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.:

Maybe you are looking for