hashtable

How to implement an associative array/map/hash table data structure (in general and in C++)

Well I'm making a small phone book application and I've decided that using maps would be the best data structure to use but I don't know where to start. (Gotta implement the data structure from scratch - school work) ...

Open Source memory mapped hash table utilities for Java

Are there any open source implementations of the following: given a set of keys and values, and a hash function, build up a hash table in a file image, such that it can then be mapped with a java.nio mapped file to avoid copying all the contents into virtual memory for lookups? ...

Sorting a hashtable based on its entry value (not the key)

I want to get the following code to work in the Java ME / J2ME environment. Please help: Hashtable <Activity, Float>scores = new Hashtable<Activity, Float>(); scores.put(act1, 0.3); scores.put(act2, 0.5); scores.put(act3, 0.4); scores.put(act5, 0.3); Vector v = new Vector(scores.entrySet()); Collections.sort(v)...

C# creating a fixed size hashtable

I want to be able to create a fixed size hashmap of say 100 buckets, and if I need to store over 100 items then collisions and overwriting will just have to happen. The hashtable class has a IsFixedSize property however it is readonly. Am I thinking about this completely wrongly, or is there a solution to this? ...

A NSDictionary that doesn't copy keys for iPhone 3.0 SDK?

Hello, I am using NSDictionary as an associated array (i.e, the keys i am using can be any arbitrary objects). One of the very annoying thing about NSDictionary is that it always make a copy of the key and store it. In my scenario, I will later retrieve the keys from the NSDictionary and do some operations with them. The operation happe...

Why does LinkedHashSet<E> extend HashSet<e> and implement Set<E>

Opened a LinkedHashSet source code today and found some interesting thing: public class LinkedHashSet<E> extends HashSet<E> implements Set<E>, Cloneable, java.io.Serializable { The question is: why do they need both "extends HashSet" and "implements Set" when HashSet already is the Set? ...

Problem with hash-table insertion function in C

Hey hey, I am trying to wrap my head around C right now (mostly how pointers operate). I am trying to write this function described below: /* EnterName enter a Name into a symbol table. Returns a boolean indicating whether an entry for Name was already listed in the table. Passes back an argu...

Why can't you use null as a key for a Dictionary<bool?, string>?

Apparently, you cannot use a null for a key, even if your key is a nullable type. This code: var nullableBoolLabels = new System.Collections.Generic.Dictionary<bool?, string> { { true, "Yes" }, { false, "No" }, { null, "(n/a)" } }; ...results in this exception: Value cannot be null. Parameter name: key Descript...

What's the point of a hash table?

I don't have experience with hash tables outside of arrays/dictionaries in dynamic languages, so I recently found out that internally they're implemented by making a hash of the key and using that to store the value. What I don't understand is why aren't the values stored with the key (string, number, whatever) as the, well, key, instead...

Contents of file as input to hashtable in Objective-C

Hello, I know to read the contents of file in Objective-C, but how to take it as the input to hashtable. Consider the contents of text file as test.txt LENOVA HCL WIPRO DELL Now i need to read this into my Hashtable as Key value pairs KEY VAlue 1 LENOVA 2 HCL 3 WIPRO 4 DELL ...

Replica of file to Hashtable

Hello, Just before i had asked you about how to take input from file into hashtable by specifying key , i'm really sorry , actually i need to seperatly identify the key and value from text file and put it into my hashtable. i.e This is text file: LENOVA = Class_Name DELL = Class_Name WIPRO = Class_Name SAMSUNG = Class_Name Ineed to t...

Does the STL contain a hashtable?

Possible Duplicates: Hashtable in C++? can anybody offer a simple hash_map example in C++? Does the STL contain an implementation of a hashtable? If so, can you provide a brief example of how to use it? ...

Should I cache the hash code of an STL string used as a hash key?

I've doing some performance analysis on the software I develop, and I've found that lookups on a global dictionary of URL's takes about 10% of the application's "load" phase time. The dictionary is implemented as a C++ STL std::map, which has O(lg n) lookups. I'm going to move it to a hash_map, which has roughly fixed time lookups. Th...

Hashtables and usage in Java

What is Hashtables used for in Java? Further more please give examples of simple usage of Hashtables. ...

Storing Class Instances In A Hashtable

I have class Foo. Foo has a property of public string x. I would like to instantiate Foo a few times as ONE and TWO, and add those instances to Hashtable Bar with keys 1 and 2 respectively. How do I obtain string x for the particular instance. I've tried something to the like of: Bar[1].x, but the property x is not recognized. What...

Comparing Hashtables in vb.net

I have a type of object called Bin, which has a hashtable field called Attributes. Like so: Public Class Bin Private _attributes As Hashtable Public Readonly Property Attributes() As Hashtable Get Return _attributes End Get End Property End Class If I have two bins, I'd like to compare if they...

What algorithms are available to resize a hash table?

I have implemented my own hash table functions in C, but currently it doesn't support resizing. I was wondering what algorithms do exist apart from the brute-force way of creating a new empty hash table and moving everything there? ...

How big is an empty Hashtable object

What is the size (in bytes) of the Hashtable object in J2ME? I mean what is the overhead for using a Hashtable? ...

Use HashTable for Temporary Data Storage After Reading Data From Database

I am looking for opinions and best coding practices. I need to get info from a database with a query such as SELECT this, that FROM MyDB (returning 2 fields). Would it be wrong to use a hashtable for temporary storage? Is there a better way to accomplish the same thing? What about if I am returning more than 2 fields, would it be be...

How do I enumerate the keys and values of a Hashtable?

Hello guys I have a problem ; I have some data and I show it with Hashtable for example I write : Enumeration keys; keys=CellTraffic_v.elements(); while(keys.hasMoreElements()) outputBuffer.append(keys.nextElement()+"\n\n"); but it show me just values how can i show values and keys together? for example this if my ke...