hashtable

data structure for multi-key data?

is there a commonly used data structure for mult-key data? e.g. (key1, key2, ..., keyN) -> value. I used to use dictionaries of dictionaries (in c#), and then wrote my own wrapper on top of this to make the syntax look a bit nicer. but it seems like I still have to write a wrapper for each N-dictionary, where N is the number of keys, sin...

Multi-valued hashtable in Java

Is it possible to have multiple values for the same key in a hash table? If not, can you suggest any such class or interface which could be used? ...

Algorithm for Determining Tic Tac Toe Game Over (Java)

I've written a game of tic-tac-toe in Java, and my current method of determining the end of the game accounts for the following possible scenarios for the game being over: The board is full, and no winner has yet been declared: Game is a draw. Cross has won. Circle has won. Unfortunately, to do so, it reads through a predefined set o...

Fast C++ container like the C# HashSet<T> and Dictionary<K,V>?

I've used HashSet and Dictionary a lot in C#, and found them very fast... I've tried using std::map and std::hash_map and am finding them very slow in comparision. Does this sound like expected behaviour? Is there something I might be doing wrong in my use of std::hash_map? Or, is there a better C++ Hash container out there? I'm has...

Please explain murmur hash?

I just found out murmur hash, seems to be the fastest known and quite collision resistance. I tried to dig more about the algorithm or implementation in full source code, but I am having difficulty understanding it. Could someone here explain the algorithm used, or implement it in full source code, preferably in C. I read the C source co...

Reversible dictionary for python

I'd like to store some data in Python in a similar form to a dictionary: {1:'a', 2:'b'}. Every value will be unique, not just among other values, but among keys too. Is there a simple data structure that I can use to get the corresponding object no matter if I ask using the 'key' or the 'value'? For example: >>> a = {1:'a', 2:'b'} >>> ...

Ran into issues while implementing hash table

I am trying to read a file which contains URLs and are 100 million in number. What I need to do is find out the different websites they are from. So, I am taking chunk of data in memory and reading it line by line. Also, I need to find out how many URLs does each website has in the file and what are those URLs. The way I figured it out i...

How to serialize a collection as an alphanumeric string?

Hi, I need to express a collection of about 10-15 short strings (and maybe some ints) as a fairly compact alphanumeric string - one which I can send as a parameter in a get request. Basically, I'm thinking that my collection will be a hashtable, and I'd like to serialize it so it looks sort of like a viewstate string (only hopefully not...

Use List<T>ForEach to add element to HashTable

I have a list of string values that I want add to a hashtable or other array that can be accessed by key/index but cannot implement it. I have this working how I want but its ugly List<string> valueList = new List<string>(); valueList.Add("1"); valueList.Add("2"); valueList.Add("3"); Hashtable p ...

.NET HashTable Vs Dictionary - Can the Dictionary be as fast?

I am trying to figure out when and why to use a Dictionary or a HashTable. I have done a bit of a search on here and have found people talking about the generic advantages of the Dictionary which I totally agree with, which leads the boxing and unboxing advantage for a slight performance gain. But I have also read the Dictionary will n...

Dynamic perfect hashing and universal hash functions - explanation please?

So I'm reading up about hash tables, hash functions etc. I was intrigued to read on wikipedia about how "dynamic perfect hashing" involves using a second hash table as the data structure to store multiple values within a particular bucket. Where I get lost however, is when it comes to how a universal hash function is selected to perfor...

Looking for a good hash table implementation in C

I am primarily interested in string keys. Can someone point me towards a library? -A ...

Publishing Concurrent Objects

I'm interested in techniques people use to publish information and changes to data structures that are being shared across multiple threads without losing much concurrency. In my personal experience I come across the single writer/multiple readers quite often, where a single thread is updating an object, but multiple threads are reading ...

C# Hashtable does not retain values

I am using a hashtable to store key-value pairs and I initialize this hashtable (ddl_ht) in the method CreateDropDownLists(). However, when I check the value of "currentItem" in my SelectedIndexChanged method, this value is null. Even though I checked the value of (string)ddl_ht[key[1]] in my Watch window and it shows a value (n...

Cocoa: Dictionary with enum keys?

I need to create a dictionary/hashmap where the Keys are enums Values are some subclass of NSObject NSDictionary won't work here (enums don't conform to NSCopying). I could perhaps use a CFDictionaryRef here, but I'd like to know if is there any other way to achieve this. ...

WPF, two-way binding to a hash table doesn't update the source object

Hi, I am wondering if anyone can help, I am able to bind to a hash table and display values correctly, yet the two-way binding I have specified doesn't update the object when I make changes. <DataTemplate x:Key="ResponseItemTemplate"> <StackPanel Orientation="Horizontal" > <TextBox Width="200" Text="{Binding Path=...

how to use Dictionary or Hashtable in Javascript?

Possible Duplicate: Can anyone recommend a good Hashtable implementation in Javascript? Hello everyone, I want to calculate/store some statistics information using JavaScript, the equivalent code in C# is below (features I need are -- key-value pair, string/int key value pair, manipulate values by keys, etc.), any ideas how to ...

Differences between .Net Hashtable, Java Hashtable & HashMap

Am I correct in saying that a .Net Hashtable is not synchronized while a Java Hashtable is? And at the same time a Java HashMap is not synchronized and has better performance? I am rewriting a Java app that makes heavy use of HashMaps in C# and I would like to use a HashTable and ensure that the performance is basically equivalent. ...

Best way to add extra values to a WinForms combo box based on a hashtable

This might be a bit of a dumb question, but I'm trying to add some extra key/value pairs to a combo box using VB.NET. The initial item list is generated from a hashtable, which contains a collection of objects. I've managed to add the extra values to the box using the Add method, however I now run into problems when reading back the sel...

How to create a case insensitive Glib Hash Table?

Is there any simply way how to create a case insensitive (String -> String) Glib Hash Table? The result should fit this: GHashTable *table; //there should be definition of table g_hash_table_insert(table, "KeY", "Something"); //insert //every command should return the line in table g_hash_table_lookup(table, "Key"); g_hash_table_look...