Questions tagged [hashtable]

A hash table in programming is a collection that uses a hash function to map identifying values (keys) to their associated values.

The basic advantage of a hash table is that they provide very efficient lookup and search functionality. Unlike many other linear collection types (such as arrays and linked lists), one does not have to loop through all the elements in a hash table searching for a particular entity.

For Java: https://docs.oracle.com/javase/8/docs/api/java/util/Hashtable.html

5453 questions
2
votes
1 answer

Read matching records from hashtable into class object

In my asp.net app I have a class that contains InstructorID and InstructorName. In the old code, I have a System.Collections.Hashtable that contains InstructorName (value) and StudentID (key). What I would like to do is add the studentID to my…
MVC Newbie
  • 23
  • 5
2
votes
4 answers

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? …
Ash
  • 24,276
  • 34
  • 107
  • 152
2
votes
1 answer

Reading from .data file into Java- how do I store the information in an array of arrays?

I have the following Java class, which I'm using to read a .data file: import java.io.*; import java.util.Scanner; public class ReadFile { static File file; String[] columns = new String[]{"personID", "lastName", "firstName", "street",…
Noble-Surfer
  • 3,052
  • 11
  • 73
  • 118
2
votes
3 answers

Perl script searching in hash table

I have programmed a Perl script which has two input files: The first file has on each line phrase and then a value between parentheses. Here an example: hello all (0.5) hi all (0.63) good bye all (0.09) The second file has a list of rules. For…
Poisson
  • 1,543
  • 6
  • 23
  • 34
2
votes
2 answers

Properly overloading [bracket] operator for hashtable get and set

I am trying to implement a hashtable class. The problem I am facing atm is how to properly overload the square bracket operators so that getting the value at a key from the hashtable is distinguishable from setting a key to a value. So far here is…
smac89
  • 39,374
  • 15
  • 132
  • 179
2
votes
2 answers

Powershell read/update/write parameter file

Part of some text file (pfile.ora) looks like…
Erik
  • 135
  • 1
  • 6
2
votes
1 answer

How to get the optimal number to use in hashtable?

As the question states, how calculate the optimal number to use and how to motivate it? If we are going to build an hashtable which uses the following hash function: h(k) = k mod m, k = key So some sources tells me: to use the number of elements…
Alexander
  • 328
  • 2
  • 10
2
votes
4 answers

How to calculate Hash value of a Tree

What is the best way to calculate the hash value of a Tree? I need to compare the similarity between several trees in O(1). Now, I want to precalculate the hash values and compare them when needed. But then I realized, hashing a tree is different…
Bidhan Roy
  • 441
  • 4
  • 14
2
votes
1 answer

Hash tables optimization

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…
Flavius
  • 13,566
  • 13
  • 80
  • 126
2
votes
4 answers

iterate through all the values of a key in hashtable java

Hashtable ht = new Hashtable(); ht.put(1,"student1"); ht.put(1,"student2"); How can I iterate through all values of "a single key"? key:1 values: student1, student2
Sara
  • 2,308
  • 11
  • 50
  • 76
2
votes
1 answer

Initial Array of pointer to pointer in Delphi

How can i Initial This Code? type PPNode = ^PNode; PNode = ^Node; CNode = array of PPNode; Node = record key: Integer; next: PNode; prev: PNode; end; i use this way : function TForm1.chained_hash_init(n: Integer):…
mohammadkad
  • 105
  • 1
  • 10
2
votes
2 answers

How to build up a hash data structure

I am having trouble figuring out how to create several %th2 structures (see below) each of which will be the values of $th1{0}, $th1{1}, and so on. I am also trying to figure out how to traverse the keys in the second hash %th2. I am running into…
octopusgrabbus
  • 10,555
  • 15
  • 68
  • 131
2
votes
1 answer

Hashmap module in node.js?

Ok, I have tried searching the web for different modules for me to use but it didn't make me any wiser. There where so many different alternatives and I couldn't find any good discussion on wich was the better. I need a hashmap with a 5 digit…
Svennisen
  • 194
  • 1
  • 9
2
votes
7 answers

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…
ST.
  • 315
  • 1
  • 4
  • 6
2
votes
1 answer

Adding hashtable to settings

I've one problem which makes me crazy. I wanted to add hashtable to settings(and added 2 hashtables), but when I tried to use it, it thrown an exception(Object reference not set to an instance of an object.). Then I looked to app.config it looked…
r.mirzojonov
  • 1,209
  • 10
  • 18
1 2 3
99
100