hashtable

mapping ipaddress range to country codes (data-structure hashmaps or trees?)

trying to solve a puzzle which i found here: http://zcasper.blogspot.com/2005/10/google-phone-interview.html the goal is to re-present a IP-Address range to country code look-up table in memory and use this data-structure to process a zilloin rows of ipaddress to identify the country code.. so i started with a shoot from the hip though...

tracking if a result has already been computed using hash table

My application would perform a large number of matrix operations (e.g., add/ multiply) on dense matrices. I would like to cache unique results in order to avoid duplicate computations. Dense matrix: typdef struct denseMatrix{ int m; int n; double **d; // actual matrix multiplyTable **entry; // key & result } dns; Table...

What does it mean by "the hash table is open" in Java?

I was reading the Java api docs on Hashtable class and came across several questions. In the doc, it says "Note that the hash table is open: in the case of a "hash collision", a single bucket stores multiple entries, which must be searched sequentially. " I tried the following code myself Hashtable<String, Integer> me = new Hashtable<S...

Hashtable in java is giving me the last stored value, but not the right value

Sorry this is kinda long, but I needed to get the right scenario. This outputs all C's, why?? thanks in advance import java.util.Hashtable; public class Main { public static ContainsTheHash containsthehash = new ContainsTheHash(); public static StoresValues storesvalues = new StoresValues(); public static GetsValuesAn...

Map pointers to immutable objects with Hashtable in .NET

I have a Hashtable object which "names" or "map" various fields in a class with a string ref class Interrupt{ Interrupt(){ this->type = 0; this->size = 0; } int type; int size; } Interrupt^ interrupt = gcnew Interrupt(); Hashtable^ map = gcnew Hashtable(); map->Add("InterruptType", interrupt->type); map->Add("Interrup...

How can I measure the performance of a HashTable in C#?

Hello everyone, I am playing around with C# collections and I have decided to write a quick test to measure the performance of different collections. My performance test goes like this: int numOps= (put number here); long start, end, numTicks1, numTicks2; float ratio; start = DateTime.Now.Ticks; for(int i = 0; i < numOps; i++) { /...

Which datastructure is appropriate for this situation?

I'm trying to decide which datastructure to use to store key-value pairs when only features needed are insertion lookup Specifically, I don't need to be able to delete pairs, or iterate through keys/values/pairs. The keys are integer tuples, the values are pointers (references, whatever). I'm only storing a couple million pairs spr...

Hash tables in prolog

I was solving a puzzle in prolog the other day and realized that were I using another programming language, I would have made use of a hash table/dictionary, but as far as I know this isn't really possible in prolog. So my first question is are there any prologs that support a dictionary-like data structure with the performance charact...

Converting integer identifiers to pointers

I have ID values of the type unsigned int. I need to map an Id to a pointer in constant time. Key Distribution: ID will have a value in the range of 0 to uint_max. Most of keys will be clustered into a single group, but there will be outliers. Implementation: I thought about using the C++ ext hash_map stuff, but I've heard thei...

Storing huge hash table in a file in Python

Hey. I have a function I want to memoize, however, it has too many possible values. Is there any convenient way to store the values in a text file and make it read from them? For example, something like storing a pre-computed list of primes up to 10^9 in a text file? I know it's slow to read from a text file but there's no other option i...

Hashmap and hashtable in multithreaded environment

I am really confused on how these 2 collections behave in multithreaded environment. Hash table is synchronized that means no 2 threads will be updating its value simultaneously right? ...

Hashtable slow to add values?

I am currently using a Hashtable to store a list of unique identifiers and associated data, all of which is read in from a file. The length of this data file can very greatly, from 1 entry to several hundred thousand. I've noticed a significant slowdown in the speed of adding entries to the Hashtable once it gets past about 50,000 entr...

Accesing a function via string stored in Hashtable

If I have function names stored as strings in a Hashtable. Is there a way to access the functions via the stored strings? EDIT I'm afraid the platform that i'm working on CLDC1.1/MIDP2.0 does not support Reflection. Any workaround possible? ...

good way to handle a bunch of data in a hash.

I'm returning a complex result of indeterminate size that I will need to handle again and again, so I'm wondering what is a good way to package it? something like this loop>>> @results = { external_id => { :name => name, :type => type } } or @results = [ { :external_id => external_id, :name => name, :type => type } ] or? end>>>...

Is there HashTable structure in Wolfram Mathematic?

Hi All I want to use a Structure like HashTable. Is there similar structure in Wolfram Mathematic? Best Regards, ...

Determining Perfect Hash Lookup Table for Pearson Hash

I'm developing a programming language, and in my programming language, I'm storing objects as hash tables. The hash function I'm using is Pearson Hashing, which depends on a 256-bit lookup table. Here's the function: char* pearson(char* name, char* lookup) { char index = '\0'; while(*name) { index = lookup[index ^ ...

Best way to create large hashmap at compile time (C++)?

In my application, I need a hash map mapping strings to a large number of static objects. The mappings remain fixed for the duration of the application. Is there an easy way to pre-generate the mappings at compile time rather than building it element-by-element when the application starts? ...

How to keep the order of elements in hashtable

I have a hashtable . values() method returns values in some order different from the order in which i am inserted.How can i get the values in the same order as i inserted?Using LinkedHashmap is an alternative but it is not synchronized. ...

How much memory does a Hashtable use?

In Java, if I create a Hashtable<K, V> and put N elements in it, how much memory will it occupy? If it's implementation dependent, what would be a good "guess"? ...

Static Hashtable with key-callback reading thread-local variable

The problem is that I have an old web service library that has a hashtable of global options which it combines with hashtable of request options. I cann't influence request code, but I can set the global hashtable. And I was just curious if there is a simple way to implement an extention to Hashtable class that will perform a callback fo...