hashtable

Is searching a HashTable slower when the key are strings and the strings contain spaces

Today I was discussing with another developer about a limitation in a third party library, where we couldn't use spaces in a string. The reasoning was that the strings were used as keys in a .NET Hashtable, and that searching a .NET HashTable was significantly slower when the keys contained spaces. Now since I'm too lazy to write a test...

how to store an hashtable or object in cookie

How to store object or hashtable in cookies? I am trying to store multiple values in hastable/class to the cookie in my asp.net mvc (C#) application. How to do it? ...

Making a perfect hash (all consecutive buckets full), gperf or alternatives?

Let's say I want to build a perfect hash table for looking up an array where the predefined keys are 12 Months, thus I would want hash("January")==0 hash("December")==11 I run my Month names through gperf and got a nice hash function, but it appears to give out 16 buckets(or rather the range is 16)! #define MIN_HASH_VALUE 3 #define M...

Anagram Hash Function

I know something like this has been asked before, but the answer was sort of side tracked. I want to develop a hash function which will take a word and spit out an address of an array. So, for example, if you input god: sort the word, d o g perform some sort of function on this to get an address d o g -> some number insert 'dog' into...

How to store a HashTable in the usersettings?

Hello, In .NET you can select a hashtable as type for a usersetting. However when I save it and retrieve it in this way, it doesnt seem to have saved it at all. Hashtable t = new Hashtable(); t.Add(1,"Foo"); t.Add(2,"Bar"); Properties.Settings.Default.Setting = t; Properties.Settings.Default.Save(); if(Properties.Settings.Default.Sett...

What's the benefit of Keyboard Accelerators added to an HashTable in .NET?

Hi, For a long time I had the following bookmark in Firefox: http://www.codeguru.com/csharp/.net/net_general/keyboard/article.php/c4639 I know decided to read it and implement it in the application it was supposed to be implemented some time ago. However, I don't see any benefit in such a method... I know that the idea behind the hast...

how to fetch DictionaryEntry object from Hashtable?

I know the value of key for my Hashtable, from key how can I obtain the object of DictinaryEntry. I don't want to Iterate over Hashtable. ...

Do all Hash-based datastructures in java use the 'bucket' concept?

The hash structures I am aware of - HashTable, HashSet & HashMap. Do they all use the bucket structure - ie when two hashcodes are similar exactly the same one element does not overwrite the other, instead they are placed in the same bucket associated with that hashcode? ...

update hashtable by another hashtable ?

How can I update the values of one hashtable by another hashtable, if second hashtable contains new keys then they must be added to 1st else should update the value of 1st hashtable. ...

Collision Resolution : Quadratic Probing vs. Separate Chaining

Ok, so I've been doing some experiments with hash tables and different collision resolution problems. I'm trying to figure out which is more efficient for doing finds, a hash table that uses separate chaining or quadratic probing for collision resolution. My results suggest that separate chaining is faster than quadratic probing even for...

Is it possible to get the value for a key in a Hashtable without iteration?

Using .NET 3.5, is there a way to retrieve a value from Hashtable corresponding to the key without iteration? ...

Hash tables optimization

Hi In several hash table implementations I've seen the usage of heuristics like "transpose" or "move to front" for items in a bucket. What are the advantages of using such heuristics? I could't figure it out myself. Which other optimizations can be done at the hash table / bucket level, why, and under which circumstances? Optimizing...

Jump Table Switch Case question

Hi. I am trying to understand some things about jump tables and its relationship between a switch case statement. I was told that a jump table is a O(1) structure that the compiler generates which makes lookup of values essentially about as fast as you can get. However in some cases a Hashtable/Dictionary might be faster. I was also tol...

How to get the key of a Hashtable entry

I've got a hashtable that I want to update from a second hashtable. For any of the keys that match I want to copy the value over. The problem I have is when I enumerate the hashtable keys and try to cast each to a string I receive an exception about casting a Guid to a String. Well it's the string I want. When you use the index operator ...

How can read a file, split the strings in it, and write the output to a hashtable in C#?

I need to read file and split string into hash table in C#. For example; 1231231 Hi this is the first entry / hi this is the second entry Currently, I'm reading the lines in the files line by line using a StreamReader, and then I splitting every line to 3 different strings. For example, "1231231" to one string, then up to "/" sign to...

Optimizing binary tree inserts to O(1) with hash map for write heavy trees

First of all I assume I've missed something major when thinking about this, but I still wanted to post about it to see if I really didn't miss anything, on with it... I have a pretty write heavy binary tree (about 50/50 between writes and reads), and on the way home today I was thinking about ways to optimize this, especially make the w...

HashTable Insert Failed. Load Factor Too High. .NET 2.0 SP2

We've just encountered this error on our web app, and immediately found the article here http://stackoverflow.com/questions/505322/hashtable-insert-failed-load-factor-too-high-asp-net-2-0. However, the hotfix that this points to (http://support.microsoft.com/?id=927579) was already included in .NET 2.0 SP1 (http://support.microsoft.com/...

What is the easiest way to sort maps according to values in Java?

I want my hash to sort in descending order according to the values. How do I do that in Java? ...

Why won't a Hashtable return true for "ContainsKey" for a key of type byte[] in C#?

Consider the following code: byte[] bytes = new byte[] { 1, 2, 5, 0, 6 }; byte[] another = new byte[] { 1, 2, 5, 0, 6 }; Hashtable ht = new Hashtable(); ht.Add(bytes, "hi"); Assert.IsTrue(ht.ContainsKey(another)); Why does this assertion fail? Being an array of a primitive type shouldn't use using the object reference, should it? S...

Is there any generic vesion of HashTable?

I need a class that will work like C++ std::map. More specifically, I need such a behavior: map< string, vector<int> > my_map; Is it possible? ...