hashtable

Hashtable with MultiDimensional Key in C#

I'm basically looking for a way to access a hashtable value using a two-dimensional typed key in c#. Eventually I would be able to do something like this HashTable[1][false] = 5; int a = HashTable[1][false]; //a = 5 This is what I've been trying...hasn't worked Hashtable test = new Hashtable(); test.Add(new Dictionary<int, bool>() ...

What is the best Distributed Hash Table Algorithm around these days?

I would like to know if the best distributed hash table algorithm is still kademlia. ...

GLib Hash Table Loop Problem

I am going to use GLib's Hash table implementation in a C program and just for now I am just experimenting with it. I wrote the following piece of code for testing: #include <glib.h> #include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <string.h> int main(){ // Some codes and declerations here GHashTable *g_hash...

How does a hash table work?

I'm looking for an explanation of how a hashtable works - in plain English for a simpleton like me! For example I know it takes the key, calculates the hash (how?) and then performs some kind of modulo to work out where it lies in the array that the value is stored, but that's where my knowledge stops. Could anyone clarify the process. ...

Hashtable/Dictionary collisions

Using the standard English letters and underscore only, how many characters can be used at a maximum without causing a potential collision in a hashtable/dictionary. So strings like: blur Blur b Blur_The_Shades_Slightly_With_A_Tint_Of_Blue ... ...

A minimal hash function for C?

I can't use boost:hash because I have to stick with C and can't use C++. But, I need to hash a large number (10K to 100k) of tokens strings (5 to 40 bytes length) so that search within those are fastest. MD5, SHA1 or any long hash function seems too heavy for a simple task, I am not doing cryptography. Plus there is the storage and com...

Looking for pseudo code for hashing algorithms (open, chaining and multiple)

Greetings, I am looking for the pseudo code for "open", "chaining" abd "multiple hashing" algorithms. Yes I have been searching for a good amount of time at google but I wasn't able to get something good. If you have a link to share, I will be greatful regards ...

Hashtable doubling?

I don't know if the title makes sense, but I am wondering how a hashtable enlarges when you add items to it? Is it like the List<T> where it doubles in size when the limit is reached? If so, then does this doubling recreates the collection from scratch (this can be answered for List<T> too, since I am not sure if that's what it does)? ...

Pointer to generic type

In the process of transforming a given efficient pointer-based hash map implementation into a generic hash map implementation, I stumbled across the following problem: I have a class representing a hash node (the hash map implementation uses a binary tree) THashNode <KEY_TYPE, VALUE_TYPE> = class public Key : KEY_TYPE; Value ...

how to add different clone objects to the HashTable in c#?

i pass a key and object to a class instaance that needs to clone that object and store it in hastable along with the key. How can i do it??? ...

Create Custom Hashtable

Hi there.. I need to create a Custom Hashtable extends java.lang.Hashtable and i need to override the get method to achieve the following behavior : if the key == null, it will return a new object of the type V if the super.get(key) == null, it will also return a new object of type V. Can anyone help me. I try to do this but I know ...

C# - parsing json formatted data into nested hashtables

I’m trying to work with some json formatted data in C#, but, I’m having some problems determining the proper way to approach the problem. My issue is that the json formatted data will be in an unknown format (I know that sounds odd … please read on). Basically, the json formatted data will be some collection of name/value pairs where t...

HashTable Java... Can you check my code

Hi, I'm writing an class for a hash table in java... can you please make sure that I am doing it correctly so far. I need to store StudentRecord objects in it.... I am calculating the hash value based on the student's ID which is of type long... package proj3; import java.util.LinkedList; public class HashTable { LinkedList<Stu...

C# Foreach Loop Hashtable Issue

I have some code which populates a hashtable with a question as the key and an arraylist of answers as the value. I want to then print out these values from the hashtable so that it displays the question and corresponding solutions for each individual question in the hashtable. I know I have done something totally stupid with the forea...

Ternary Tree Vs Hash Table

I need to know if a ternary tree is better than a hash table. I came across this question in a reply to another question I had where someone said that ternary trees are often faster than hash tables. I found that hard to believe, so I decided to research a little into it. This one website from Princeton appears to be the source of the...

Run time to insert n elements into an empty hash table

People say it takes amortized O(1) to put into a hash table. Therefore, putting n elements must be O(n). That's not true for large n, however, since as an answerer said, "All you need to satisfy expected amortized O(1) is to expand the table and rehash everything with a new random hash function any time there is a collision." So: what ...

Why this code doesn't allocate memory in C?

Updated question is here http://stackoverflow.com/questions/828108/please-help-me-to-solve-this-memory-allocation-problem I'm working on making a HashTable in C. This is what I've done. I think I'm going on a right path but when I'm trying to main.c HashTablePtr hash; hash = createHashTable(10); insert(hash, "hello"); insert(hash, "...

three item HashMap without internal iteration

What is the best way to implement a three item hashMap? For example, I would like to use a regular String key , but have it map to two different objects. The idea is like having a list of lists, except that the first item is a key. I am trying to avoid iterating through the list ( so the behavior is like a hashmap ). Would you agree the...

Most concise way to initialize a C# hashtable

Does C# allow hashtables to be populated in one-line expressions? I am thinking of something equivalent to the below Python: mydict = {"a": 23, "b": 45, "c": 67, "d": 89} In other words, is there an alternative to setting each key-value pair in a separate expression? ...

Top 10 Frequencies in a Hash Table with Linked Lists

The code below will print me the highest frequency it can find in my hash table (of which is a bunch of linked lists) 10 times. I need my code to print the top 10 frequencies in my hash table. I do not know how to do this (code examples would be great, plain english logic/pseudocode is just as great). I create a temporary hashing list ...