hashmap

How to get a sorted result in iBatis ?

I have a table mgr_employee with 2 columns managerName, teamEmployee.Although I do a sort in sql I get unsorted resultMap in java. How can I get a sorted map? Why does iBatis mix up the resultMap? <resultMap id="s_filter_defaults_ResultMap" class="java.util.HashMap"> <result property="key" column="managerName"/> <result property="v...

Loop Java HashMap like Python Dictionary?

In Python, you can have key,value pairs in a dictionary where you can loop through them, as shown below: for k,v in d.iteritems(): print k,v Is there a way to do this with Java HashMaps? ...

C++: is the unordered_map really unordered?

I am very confused by the name 'unordered_map'. The name suggests that the keys are not ordered at all. But I always thought they are ordered by their hash value. Or is that wrong (because the name implies that they are not ordered)? Or to put it different: Is this typedef map<K, V, HashComp<K> > HashMap; with template<typename T> s...

Thread safe Hash Map ?

Hi Guys, I am writing an application which will return a HashMap to user. User will get reference to this MAP. On the backend, I will be running some threads which will update the Map. What I have done so far? I have made all the backend threads so share a common channel to update the MAP. So at backend I am sure that concurrent wri...

Iterating over a HashMap of HashMaps in Java (or Scala)

I created a class Foo that has the method toArray() that returns an Array<Int>. Now, I have a HashMap mapping Strings to HashMaps, which map Objects to Foo. That is: HashMap<String,HashMap<Object,Foo>> And I want to create a new object of type: HashMap<String,HashMap<Object,Array<Int>>> That is obtained by calling the function toA...

What else can I use instead of a HashMap?

Hi, In my project, I get entries of a form from two servers and keeping them in a hashmap. key is serverName and value is 2d ArrayList (ArrayList<ArrayList<Object>>) In ArrayList, I keep the values of fields that belong to the form on that server. I compare these values in two server and print them to an excel file. My problem is t...

ANSI C hash table implementation with data in one memory block

Hello, I am looking for an open source C implementation of a hash table that keeps all the data in one memory block, so it can be easily send over a network let say. I can only find ones that allocate small pieces of memory for every key-value pair added to it. Thank you very much in advance for all the inputs. EDIT: It doesn't necess...

using static dictionary as cache may lead to leak problem ?

hello all, I have memory leak in the web application (servlet) that I am working on. I am suspicious of 1 cause and wanted to hear your ideas about it. I use hashmaps,hashsets etc. as DB (about 20MB data loaded). These maps,sets get reloaded once in every 10 min. There are huge amount of simultaneous requests. I read that, GC passes ob...

Super high performance C/C++ hash map (table, dictionary)

I need to map primitive keys (int, maybe long) to struct values in a high-performance hash map data structure. My program will have a few hundred of these maps, and each map will generally have at most a few thousand entries. However, the maps will be "refreshing" or "churning" constantly; imagine processing millions of add and delete m...

What is inside an empty index of a Hashmap?

I have a hashmap that is 101 keys in size, but I know for sure about 6 of those have no data inside, and there may be more without data as well. What exactly is inside the empty indexes? Is it null? or is there a Hash(index).isEmpty() method that I can use to see if its empty? I realize there is a isEmpty method inside hashmap, but I th...

Is there a hashmap library for JavaScript?

In JavaScript, all Objects act a bit like hashmaps. However, the keys to these hashmaps must be strings. If they're not, they're converted with toString(). That means: var a = {foo: 1}; var b = {bar: 2}; var o = {}; o[a] = 100; o[b]; // 100 JSON.stringify(o); // '{"[object Object]":100}' That is, since the toString() o...

java disc based hashmap

I'm working on a web crawler (please don't suggest an existing one, its not an option). I have it working the way it is expected to. My only issue is that currently I'm using a sort of server/client model where by the server does the crawling and processes the data, it then put it in a central location. This location is an object create...

HashMap Implementation question

HashMap contains a hash-table which is an array that hold the values as I understood the hash-table has an initial size, yet it can get increased after many invocation of put() (depends on the load-factor) anyhow I wonder how can you find a value after you change the size of the hash-table because I know that in order to calculate the ...

java hashmap key iteration

Is there any way to iterate through a java Hashmap and print out all the values for every key that is a part of the Hashmap? ...

java hashmap query

Hi guys, Im reading values from a file and storing these values in a hashmap, using a bufferedreader, in the following manner -- while((String str=buffread.readLine()).length()>1) { hashMap.put(str.substring(0,5),str); } I can also verify that the hashmap has all data that was initially presen...

How to read and write a HashMap to a file ?

I have the following HashMap: HashMap<String,Object> fileObj = new HashMap<String,Object>(); ArrayList<String> cols = new ArrayList<String>(); cols.add("a"); cols.add("b"); cols.add("c"); fileObj.put("mylist",cols); I write it to a file as follows: File file = new File("temp"); FileOutputStream f = new FileOutputSt...

"Transpose" a hashmap for key->value to value->key?

Say I have a map of key -> value pairs, I want to reverse this so that I have a new map which is effectively value -> key (i.e. the old value becomes the new key and the old key becomes the new value). Whats the best way to do this? (I am using Java...). Oh and values are unique. ...

IBatis + Java: Retrieving HashMap

Hi, How can I retrieve a HashMap using IBatis. I have a select for two values, and I want to maps this in a key-value map. Someone has faced the same problem? Thanks in advance ...

Eclipse Warning with Java HashMap

Eclipse is saying "HashMap is a raw type" When I use the following code HashMap = new HashMap(); Any idea what could be wrong? ...

Strange Java HashMap behavior - can't find matching object

I've been encountering some strange behavior when trying to find a key inside a java.util.HashMap, and I guess I'm missing something. The code segment is basically: HashMap<Key, Value> data = ... Key k1 = ... Value v = data.get(k1); boolean bool1 = data.containsKey(k1); for (Key k2 : data.keySet()) { boolean bool2 = k1.equals(k2); ...