Collection MAP HASh map hash table

Hi
i wan to be familiar with Collection MAP API hasp map & hash table
please guide me...
tell me resource link where i can get more information about it.
Bunty

Thanks Jos
it is more theortical You just skimmed through it for at most eleven minutes. How can you
tell it's 'more theoretical'? It is a tutorial you know ...
kind regards,
Jos

Similar Messages

  • Iterator over a hash table map

    How can I implement an iterator method ( public Iterator keyIterator() { }
    ) so that it would iterate over the key in a hash table map data structure. Thanks

    Map has a method called ketSet. Read it's docs. It's a Set. Set has iterator().
    There's also entrySet() and values().
    Read their docs and see which one works best for you.
    You may also want to check out this tutorial:
    http://java.sun.com/docs/books/tutorial/collections/

  • How  Hash tables can be used  in PI mapping

    Hi Experts,
    I'm don't have any idea how we store the values in hash tables and how to implement them in mapping.
    In my scenario I have two fields matnum and quantity.if matnum is not null ,then we have to check whether the matnum exists in hash table and also check whether the hash table is empty or not.
    How we can do this in graphical message mapping? 
    how to store the variable matnum in a table?
    If global variables are used, how to implement in mapping.how we call the keys from hash table ?

    Divya,
    We have a similiar requirement for getting different values. Below param1 may you be matnum,param2 is quantity
    What you need to do is first declare global varaible(A), fill hash table as below(B) and retrieve(C) based on index. You can tweak code based on your requirement
    (A) Declare global variable(last icon in message mapping tool bar)
         String globlalString[] = new String[10];
    (B) Fill Hash Table
    import java.util.Hashtable;
    public void saveparam1(String[] param1,String[] param2,ResultList result,Container container){
    Hashtable htparam1 = new Hashtable();
    int Indx = 0;
    for (int i = 0 ;i < param1.length ; i++) {
      String strparam1 = param1<i>.trim();
      if (strparam1.length() > 0) {
        Object obj = htparam1.get(strparam1);
        if (obj == null){
          globlalString[Indx++] = strparam1 ;
          htparam1.put(strparam1,strparam1);
    if (Indx < globalString.length) {
      for (int i = 0;  i < param2.length ; i++) {
        String strparam2 = param2<i>.trim();
        if (strparam2.length() > 0) {
          Object obj = htparam1.get(strparam2);
          if (obj == null){
            globalString[Indx++] = strparam2 ;
            htparam1.put(strparam2,strparam2);
    result.addValue(globalString[0]); // for first value
    (C) for subsequent reading/accessing
    //pass constant whatever number is required to this function
    String retValue = "";
      int indx = Integer.parseInt(index);
      indx = indx - 1;
      if ((indx >= 0) && (indx < globalString.length)){
       retValue = globalString[indx];
    return retValue;
    Hope this helps!

  • Hash table/Collection

    How do you translate a hash table to a collection? Specifically with the Vector class.

    That question doesn't really make sense. You can easily take data in a hashtable and put it in a subclass of Collection, but how one does so, or whether it's appropriate, is doing to depend on the situation. There isn't a "this is how you do it" answer to this.
    By the way, Hashtables are a collection, in the sense of being part of the Collections Framework, although not in the sense of being a subclass of Collection.

  • Comparing String values against a collection of Names in a Hash Table

    Objective:
    Is to make a script that will import a csv file containing two values: "Name" and "Price". This would ideally be stored in a hash table with the key name of "Name" and the value being "Price". The second part would be
    importing a second csv file that has a list of names to compare too. If it finds a similar match to a key name in the hash table and then it will add that to a new array with the price. At the end it would add all the prices and give you a total value.
    The Problem to Solve:
    In the real world people have a tendency to not write names exactly the same way, for example I am looking at a list of books to buy in an eBay auction. In the auction they provide a text list of all the names of books for sale. In my price guide it has all
    the names and dollar values of each book. The wording of the way each book is named could differ from the person who writes it and what is actually in my reference pricing list. An example might be "The Black Sheep" vs "Black Sheep" or
    "Moby-Dick" vs "Moby Dick".
    I've tried making a script and comparing these values using the -like operator and have only had about 70% accuracy. Is there a way to increase that by 
    comparing the characters instead of likeness of words? I'm not really sure how to solve this issue as it's very hard to do quality check on the input when your talking about hundreds of names in the list. Is there a better way to compare values in power-shell
    then the "like" operator? Do I need to use a database instead of a hash table? In the real world I feel like a search engine would know the differences in these variations and still provide the desired results so why not for this type of application?
    In other words, create a bit more intelligence to say well it's not a 100% match but 90% so that is close enough, add it to the array as a match and add the price etc..
    I'd be curious as to any thoughts on this? Maybe a scripting language with better matching for text?

    Have you considered setting up a manual correction process that "learns" as you make corrections, automatically building a look up table of possible spellings of each Name?  If you get an exact match, use it.  If not, go to the look up
    table and see if there's been a previous entry with the same spelling and what it was corrected to.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • How to store a text file in a hash table in C#?

    I am fairly new to c#. I am creating a console application project for practice. I am supposed to create a program that reads a text file (it's a poem), store it in a hash table, have two different sorts, and unhash the table. I managed to get the poem read
    by using streamwriter, but now I am not sure how to store it in a hash table. 
    I'm not sure if I am doing this hash table correct, but I made my hash table like this to store the text file: 
          Hashtable hashtable = new Hashtable();
                hashtable[1] = (@"C:\\Documents\\Datastructures\\Input\\Poem");

    Hi,
    Hashtable in C# represents a collection of key/value pairs which maps keys to value. Any non-null object can be used as a key but a value can. We can retrieve  items from hashTable to provide the key . Both keys and values are Objects.
    Here is a sample about Hashtable,
    Hashtable weeks = new Hashtable();
    weeks.Add("1", "SunDay");
    weeks.Add("2", "MonDay");
    weeks.Add("3", "TueDay");
    weeks.Add("4", "WedDay");
    weeks.Add("5", "ThuDay");
    weeks.Add("6", "FriDay");
    weeks.Add("7", "SatDay");
    //Display a single Item
    MessageBox.Show(weeks["5"].ToString());
    //Search an Item
    if (weeks.ContainsValue("TueDay"))
    MessageBox.Show("Find");
    else
    MessageBox.Show("Not find");
    //remove an Item
    weeks.Remove("3");
    //Display all key value pairs
    foreach (DictionaryEntry day in weeks)
    MessageBox.Show(day.Key + " - " + day.Value);
    >>I managed to get the poem read by using streamwriter, but now I am not sure how to store it in a hash table
    Hashtable hashtable = new Hashtable();
    hashtable[1] = (@"C:\\Documents\\Datastructures\\Input\\Poem");
    But follow your scenario above, you just store a string path to hashtable not a file.
    About saving data to a file, you can use the following code.
    // Write the string to a file.
    System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
    file.WriteLine(lines);
    file.Close();
    Best wishes!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Implementing a threaded Hash Table

    Hiya all,
    Would like to know how to create a threaded hash table. I am making a program that should be able to take in different variables such as string and integers, and be able to store then in a Hash table. Would it be possible to retreive these variables (remove them from the hash map) in a threaded scenario?

    Unlike the new collection implementations, Hashtable
    is synchronized.True, but HashMap is more stable. Its performance stays roughtly the same when it's loaded with different (biased) data sets whereas Hashtable shows much more variation.

  • Hash Table Extract

    Hi,
    I'm hoping that someone will be able to explain how I extract the first element (in this case the name) from the hashtable in the server code below (case N:).
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class Server{
      private PrintWriter pw;
      private BufferedReader bf;
      private ServerSocket ss;
      private Socket s;
      //Hashtable used to store test data
      //Set up hash table with test data
      private Hashtable emails;
      public Server() throws Exception{
        emails = new Hashtable();
        emails.put("Ince","[email protected]");
        emails.put("Roberts","[email protected]");
        emails.put("Timms","[email protected]");
        emails.put("Rowlands","[email protected]");
        emails.put("Eustace","[email protected]");
        emails.put("Lord","[email protected]");
          System.out.println("...Setting up server socket");
          ss = new ServerSocket(1200);
          System.out.println("..waiting for connection ");
          s = ss.accept();
          System.out.println("..connection made");
          InputStream is = s.getInputStream();
          bf = new BufferedReader(new InputStreamReader(is));
          OutputStream os = s.getOutputStream();
          pw = new PrintWriter(os, true);
        public void  Run() throws Exception
        boolean cont = true;
        while(cont == true)//server runs while true
          String clientLine = bf.readLine();
          System.out.println( clientLine ); //used to check the connection
          switch(clientLine.charAt(0))
          case'E':
            String Name = "";
            String staffName = null;
            Name = clientLine.substring(1,clientLine.length());
            staffName = (String) emails.get(Name);
            pw.println(staffName);
            break;
          case'N':
            String email = "";
            String emailAddress = null;
            email = clientLine.substring(1,clientLine.length());
            emailAddress = (String) emails.get(email);
            pw.println(emailAddress);
            break;
          case'U':
            String number = (String) emails.get(clientLine);
            if(number == null)
            pw.println(number);
            break;
          case'Q':
            pw.close();
            bf.close();
            s.close();
            cont = false;
          break;
        public static void main(String[]args) throws Exception{
          Server serv = new Server();
          serv.Run();
    }

    1) Use HashMap if possible, rather than Hashtable.
    2) HashMap and Hashtable don't have a "first" element. You can call entrySet(), keySet(), or values() and get the first element from the resulting collection's iteration, but that could be any element from the map--first added, last added, middle. It has no relation to the order added or to any sorting.
    If you want to retrieve in the order added, use LinkeHashMap.
    If you want to retrieve in a sorted order, use a SortedMap, such as TreeMap.
    Make sure you implement equals and hashCode correctly, and if you want to sort, implement Comparable or provide a Comparator.
    http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf
    Making Java Objects Comparable
    http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html
    http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html

  • Hash Table efficiency question

    Hi experts,
    In my program, I want to read in a lot of string and store the occurance of each string. I found that hash table is the best and most efficient option, but the problem is that, hash table only store one item.
    So, I either have to:
    1) store an array object into each hash table entries. ie String[String][Occurance]
    2) create two hash table based on the hash code of the string.
    For 2) I am planning to store all distinct String into one hashtable using the string as the hashcode, then create another hashtable to store the occurance using the String as the hashcode.
    My question is that:
    1)which implementation is more efficient? Constantly creating String array for each entry or create two hashtables?
    2) Is the second implementation possible? Would the hashcode be mapped to different cell in the hashtable even the two hashtable are using the same hashcode and the same size?
    Thank you very much for your help.
    Kevin

    I am wondering what it is you are trying to do, but I am assuming you are trying to find the number of occurrences for a particular word, and then determining which word has the highest value or the lowest value? You can retrieve the initial String value by using the keys() method of the hashtable. You can use it to traverse the entire table and compare the counts there.
    If you really wanna store another reference for that string, create a simple object
    public final class WordCount {
       * The Word being counted.
       * @since 1.1
      private String _word;
       * Count for the Number of Words.
       * @since 1.1
      private int _count;
       * Creates a new instance of the Word Count Object.
       * @param word The Word being counted.
       * @since 1.1
      public WordCount(final String word) {
        super();
        _word = word;
        _count = 0;
       * Call this method to increment the Count for the Word.
       * @since 1.1
      public void increment() {
        _count++;
       * Retrieves the word being counted.
       * @return Word being counted.
       * @since 1.1
      public String getWord() {
        return _word;
       * Return the Count for the Word.
       * @return Non-negative count for the Word.
       * @since 1.1
      public int getCount() {
        return _count;
    }Then your method can be as follows
    * Counts the Number of Occurrences of Words within the String
    * @param someString The String to be counted for
    * @param pattern Pattern to be used to split the String
    * @since 1.1
    public static final WordCount[] countWords(final String someString, final String pattern) {
      StringTokenizer st = new StringTokenizer(someString, pattern);
      HashMap wordCountMap = new HashMap();
      while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (wordCountMap.containsKey(token)) {
          ((WordCount) wordCountMap.get(token)).increment();
        } else {
          WordCount count = new WordCount(token);
          count.increment();
          wordCountMap.put(token, count);
      Collection values = wordCountMap.values();
      return (WordCount[]) values.toArray(new WordCount[values.size()]);
    }Now you can create your own comparator classes to sort the entire array of Word Count Objects. I hope that helps
    Regards
    Jega

  • How to use one hash table inside another hash table

    Hi everyone,
    Any example of hash table inside another hash table.
    Can one here help me how to write one hash table inside another with repeating keys for the first hash table.
    Thanks,
    kanty.

    Do you mean you want the 'value' entries in a hash table to themselves be hash tables? Easy but this often indicates a design flaw.
    Hashtable<String,<Hashtable<String,Value>> fred = new Hashtable<String,<Hashtable<String,Value>> ();But what do you mean by "with repeating keys for the first hash table"?
    Edited by: sabre150 on Jul 2, 2010 10:11 PM
    Looks like you have already handled the declaration side in your other thread. I suspect you should be writing your own beans that hold the information and these beans would then be stored in a Map. The problem I have is that your description is too vague so I can't be certain.

  • Hash Table Infrastructure ran out of memory Issue

    I am getting ORA-32690 : Hash Table Infrastructure ran out of memory error, while executing an Informatica mapping using Oracle Database ( Test Environment)
    The partition creation is as shown below.
    TABLESPACE MAIN_LARGE_DATA1
    PARTITION BY LIST (MKTCD)
    PARTITION AAM VALUES ('AAM')
    TABLESPACE MAIN_LARGE_DATA1,
    PARTITION AHT VALUES ('AHT')
    TABLESPACE MAIN_LARGE_DATA1,
    PARTITION GIM VALUES ('GIM')
    TABLESPACE MAIN_LARGE_DATA1,
    PARTITION CNS VALUES ('CNS')
    TABLESPACE MAIN_LARGE_DATA1,
    PARTITION AOBE VALUES ('AOBE')
    TABLESPACE MAIN_LARGE_DATA1,
    PARTITION DBM VALUES ('DBM')
    TABLESPACE MAIN_LARGE_DATA1
    Could you please provide me with a solution to this problem asap?

    SQL statement and execution plan? Is there a server-side trace file created for the session?
    From the brief description, it sounds like bug 6471770. See Metalink for details. The workaround for this particular bug is to either disable hash group-by, by setting +"_gby_hash_aggregation_enabled"+ to FALSE (using an ALTER SESSION statement . Or by using a NO_USE_HASH_AGGREGATION hint.
    Suggest you research this problem on Metalink (aka MyOracleSupport at https://support.oracle.com)

  • Date Object as a key in Hash table

    Hi,
    I'm having a hash table with date object as key , the purpose is I can pick the value which is available in given date range. Consider the below example
    Coffee Powder[Code CODE1] - Effective 21-Jan & Expiry 20-Jun
    Coffee Powder[Code CODE1] - Effective 22-Jun & Expiry 30-Dec
    Meat[Code CODE2] - Effective 21 - Jan & Expiry 1 - Feb
    Meat[Code CODE2] - Effective 2 Feb &  Expiry 6 - Feb
    Currently I'm using the following hashtable & it has the structure Key - Code & Value [ List of objects] ]
    CODE1- List[ Coffe Powder - 21 Jan - 20 Jun , Coffee Powder - 22 Jun - 30 Dec ]
    CODE2- List[ Meat - 21 Jan - 01 Feb, Meat - 02 Feb - 06 Feb ]
    To get the value which is valid for the given date , i need to get the list by passing the code & iterate the list to get the best matched value.
    Example , if I want the Coffee Powder Information which is valid on 1 Feb. I need to get pass the code ( CODE 1 ) which will returns the list of objects. After we need to iterate the list to get the best match.
    Instead of iteration , is there any way to maintain the hashtable & get the results quicker..?
    Thx.

    To get a benefit out of the HashMaps quick access to keys you you'd need an exact match between your search date and a key date.
    Can you cluster your Map-Content? eg.: do you always serch for a complete month?
    Then you could change your Map from Map<Date,Object> to Map<Date,List<Object>> where Date is "normalised" to the first Day in month 00:00 o clock (UTC or local...).
    You could also consider an additional map (Map<Date,List<Date>>) where you group the actual keys of the original Map by the expected search clusters.
    bye
    TPD

  • Swing and hash table

    i have program that reveived the input through JTextField ,
    then i want it to search for that value in hash table and display it in an JTextArea,
    i only don't know how to search the value of input in the hash table and display it in JTextArea?

    xtremliep wrote:
    Hi dapim,
    have a look at the example here:
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Hashtable.html
    If your Hashtable looks like this:
    Hashtable numbers = new Hashtable();
    numbers.put("one", new Integer(1));
    numbers.put("two", new Integer(2));
    numbers.put("three", new Integer(3));You could access it like this
    Integer n = (Integer)numbers.get(JTextField.getText());
    - use the interface not the implementation as declaring type
    - use HashMap not Hashtable if it's only accessed by a single thread
    - use generics
    - use autoboxing to allow the reuse of objects
    So this code would look like this:
    Map<String, Integer> numbers = new HashMap<String, Integer>();
    numbers.put("one", 1);
    numbers.put("two", 2);
    numbers.put("three", 3);
    int n = numbers.get(myTextField.getText());-Puce

  • Hash table order

    I only need to put 7 key-values pairs in a hashtable. i've used the default initial capacity and load factors ie 11 and 0.75, but when debugging i find that the hash table calls rehash(), which changes the order in which i enter these key-value pairs. I've tried changing the initial capacity and load factors but still get a rehash at some point in time. I've also tried HashMap with the same result. Is there any other Map implementation that can guarantee results in the order in which i enter them without changing them somewhere along the line, cos i really need them in the order i enter them.
    Thanks guys for ur help in advance.

    I only need to put 7 key-values pairs in a
    hashtable. i've used the default initial capacity and
    load factors ie 11 and 0.75, but when debugging i
    find that the hash table calls rehash(), which
    changes the order in which i enter these key-value
    pairs. I've tried changing the initial capacity and
    load factors but still get a rehash at some point in
    time. I've also tried HashMap with the same result.
    Is there any other Map implementation that can
    guarantee results in the order in which i enter them
    without changing them somewhere along the line, cos i
    really need them in the order i enter them.
    Thanks guys for ur help in advance.would this do ?
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedHashMap.html

  • Java : hash table

    hi sdn folks
    I have a question regarding hash table and how we use it in xi.
    In GLobal variables section it is defined:
    Map employee = new HashMap();
    Suppose I have a hash table defined in global variables section as in Initialization section:
      Map office;
        office = new HashMap();
        office.put("01", "001");
        office.put("02", "002");
        employee.put("90008", office);
    Can anyone explain what it means,I dont understand this code?
    Rgds

    Hi,
    HashMap define a structure with key/value pair, where you can access a value by key.
    In this example, was defined a map to insert employees identified by a key. In this structure you can put any Java Object , including other Map.
    Map employee = new HashMap();
    Was defined too another structure to insert Offices.
    office = new HashMap();
    office.put("01", "001");
    office.put("02", "002");
    And the line bellow you assign the office map with them employee identified by 90008.
    employee.put("90008", office);
    So you can do something like:
    Get Office Map to employee 90008:
    Map office = employee.get("90008");
    Now get Office identified by 01 of Employee 90008
    office.get("01");
    In summary, with Map you can mantain data of any type by a key.
    Best regards

Maybe you are looking for

  • Problems with EFI Firmware Update to 1.5 for mid 2010 Mac Pro, and sleep issues

    Hello to the community, I have run into an annoying issue. I need to update the EFI firmware on my 8 core mid-2010 Mac Pro. I downloaded the EFI update from the apple website from here : http://support.apple.com/kb/DL1321 But everytime I download it,

  • Get decline event in VSTO

    We need to handle decline event for outlook add-in. But on decline an appointment, cancel event is getting executed as appointment is moved to delete folder from the default folder. I tried solution given in the below link http://stackoverflow.com/qu

  • 2007 Mac Pro (10.6.8) cannot upgrade to Yosemite?

    Hi everyone. first time posting. I've just tried to upgrade my Late 2007 Mac Pro desktop to Yosemite (from Snow Leopard 10.6.8) and got this message: "This version of OS X 10.10 cannot be installed on this computer." I dug a bit deeper.... and found

  • Extra internal HD not showing up

    Hi all, My laCie d2 external drive packed up, and just before I was going to toss it in the trash, I took it out of the enclosure and put it in my G4 (1.25d). It works! ...but only if I disconnect 1 of my other internal drives. I have a 70g Seagate d

  • Data Modeler - Source/Target Name

    I have imported a logical model from Oracle Designer and need to show the "source/target" names. I could do this easily in version 2 of the Data Modeler through the Logical Model , "Show Source/Target Name" option of the Diagram pane (from Tools | Ge