hashtable

What is the fastest dictionary based class implementation?

Which one of the C# <Key, Value> structure implementations has better performance and higher speed? P.S.1: I Have two thread, one of them writes into collection, and another one reads and writes into it. P.S.2: Key items are random numbers, and then my access is random. Write and read actions are simultaneous. I am using hashtable, but...

Two hash tables, hash table with double key or different solution?

Hi, Once again, talking about my upcoming university project... I had a class today, where we could ask stuff about the project but I still haven't decided on the best way to do this. Basically, I have a bunch of users (some struct with a couple of members) which must be quickly searched by name and by SSN. Since I will also need to us...

Hashtable/Dictionary but with key composed of multiple values?

Lets say I have an object that has stringProp1, stringProp2. I wish to store each combination of stringProp1, stringProp2 in a Dictionary. Initially I was storing the key as key = stringProp1+stringProp2 but this can actually cause a bug depending on the 2 values. Is the best solution for this problem to create a custom dictionary cla...

Why are hash table expansions usually done by doubling the size?

I've done a little research on hash tables, and I keep running across the rule of thumb that when there are a certain number of entries (either max or via a load factor like 75%) the hash table should be expanded. Almost always, the recommendation is to double (or double plus 1, i.e., 2n+1) the size of the hash table. However, I haven'...

Is ActionScript 3 Dictionary a hashmap?

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/ The dictionary does what I need but I do need to care about performance. Does anybody know if the Dictionary is implemented as hashmap? ...

Hash table in Rails

Hello, I have the following hash table: COUNTRIES = { 'France' => 'FR', 'German' => 'GE', 'United Kingdom' => 'UK' } I have it in my model and use it in my views so the countries are displayed as a select box. Now I have one view where I want all those values plus one more value "Europe" => 'EU' to be shown. Meaning I wou...

coding inspiration needed - keywords contained within string

Hi all I have a particular problem and need to know the best way to go about solving it. I have a php string that can contain a number of keywords (tags actually). For example:- "seo, adwords, google" or "web development, community building, web design" I want to create a pool of keywords that are related, so all seo, online marke...

Is there a way to keep track of the ordering of items in a dictionary?

I have a Dictionary<Guid, ElementViewModel>. (ElementViewModel is our own complex type.) I add items to the dictionary with a stock standard items.Add(Guid.NewGuid, new ElementViewModel() { /*setters go here*/ });, At a later stage I remove some or all of these items. A simplistic view of my ElementViewModel is this: class ElementVi...

How stupid it is to use an integer value a key for an Hash Table?

Hi, I'll be needing to use Hash Tables with different keys. One as string for the key and another as integer. As for the integer one, how stupid it is to run a hash function on the number to generate a key? I mean, the numbers I'll be using as key for the Hash Table will always be different, there will be no duplicates at all. Isn't e...

What kind of overhead is involved in a Hashtable ?

I understand that since allocation is at run-time there must be some house-keeping operations involved. But other than that what is the overhead ? Also, would it be wise to create a hashtable Vs array when you need to store the number of times an integer element appears in an infinite stream of numbers ? ...

Recommended low memory hashmap for implementation for Java

I am currently working on a programming related problem where I am attempted to make a massive hashmap of data. The key for the data is a custom low-memory implementation of a CharSequence that implements hashCode() and equals(...) and the value is am Integer object. There may be millions of entries in this hashtable and I managed to d...

Get size of ActionScript 3 Dictionary

var d:Dictionary = new Dictionary(); d["a"] = "b"; d["b"] = "z"; How to get the length/size of the dictionary (which is 2) ? ...

Change the array KEY to a value from sub array

Hello, This is the set of result from my database print_r($plan); Array ( [0] => Array ( [id] => 2 [subscr_unit] => D [subscr_period] => [subscr_fee] => ) [1] => Array ( [id] => 3 [subscr_unit] => M,Y [subscr_period] =...

A few questions about my modular code using void* as dynamic data type in C

Hi, A few days ago I posted this question and everyone suggested me to use void*, which I did. I think some of them also pointed a few things that I would need to take care of but I'm not sure what exactly were they. However, I'm having a few problems with this... I'm not going to post all my code where cause it's quite large, instead,...

Hashtable comparator problem

Hi guys i've never written a comparator b4 and im having a real problem. I've created a hashtable. Hashtable <String, Objects> ht; Could someone show how you'd write a comparator for a Hashtable? the examples i've seen overide equals and everything but i simply dont have a clue. The code below is not mine but an example i found, the ...

.NET Hashtable - "Same" key, different hashes

Is it possible for two .net strings to have different hashes? I have a Hashtable with amongst others the key "path". When I loop through the elements in the table to print it, i can see that the key exists. When trying to looking it up however, there is no matching element. Debugging suggests that the string I'm looking for has a differ...

unsort Hashtable

hi there i am writing a program in C# i have a code like this Hashtable ht = new Hashtable(); ht.Add("1", "One"); ht.Add("2", "Two"); ht.Add("3", "Three"); ht.Add("4", "Four"); but Compiler sort it i wanna know how can i prevent sorting hashtable please help me ...

Sort by values from hash table - Ruby

Hello, I have the following hash of countries; COUNTRIES = { 'Albania' => 'AL', 'Austria' => 'AT', 'Belgium' => 'BE', 'Bulgaria' => 'BG', ..... } Now when I output the hash the values are not ordered alphabetically AL, AT, BE, BG ....but rather in a nonsense order (at least for me) How can I output the hash having the ...

Hash Table v/s STL map in C++

Hi, I am trying to learn C++ maps. Was just wondering about the implementation of STL map. I read it employs Binary search tree. Is there a implementation of hash table in STL? How exactly do STL map stores Key Value pairs? ...

retrieve value from hashtable with clone of key; C#

I would like to know if there is any possible way to retrieve an item from a hashtable using a key that is identical to the actual key, but a different object. I understand why it is probably not possible, but I would like to see if there is any tricky way to do it. My problem arises from the fact that, being as stupid as I am, I creat...