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
2 answers

How I display the content of my hash table in java

I implemented a hash table and I want to display the contents, but I do not know how to do this. Here is my driver class: package myHashTable; import java.util.InputMismatchException; import java.util.Scanner; public class…
user2976636
  • 95
  • 1
  • 1
  • 12
2
votes
1 answer

checking the string against all values of multidimension hashmap in perl

I have the below requirements Read the sample data file /tmp/user_defined_connection.ini MANAGEMENT=IDL||CIDL NORTH=IDL,NORTHERN||VIDL,NORTH||IDL,NORTH SOUTH=IDL,SOUTHERN||CIDL,SOUTH||IDL,SOUTH Each Key here can have the multiple such values…
learner
  • 365
  • 1
  • 2
  • 14
2
votes
1 answer

reHashing a table

I am trying to rehash a table by deleting old table and creating a new bigger table with same contents. I created a reHash function, but this function gives memory leaks, causing the program to crash when the function is executed. I can't find my…
Sargis Plus Plus
  • 45
  • 1
  • 3
  • 11
2
votes
3 answers

How to write a correct Hash Table destructor in c++

I am writing a c++ Hashtable Here is my destructor: HashMap::~HashMap() { for (int i=0; i
user3000888
  • 353
  • 1
  • 6
  • 13
2
votes
2 answers

.NET hashtable: How to simulate "Load factor too high" exception

Our production repeatedly met "Hashtable insert failed. Load factor too high". 1. How could I simulate this kind of exception? 2. If this sort of exception is thrown, would the existing key/value will disappear? Thanks for any help.
Ricky
  • 34,377
  • 39
  • 91
  • 131
2
votes
3 answers

How to refactor this Ruby sanitize hash method to make it more idiomatic?

This method takes a hash and returns a new hash without sensitive information. It does not modify the hash passed in. Is there a more Ruby-like, idiomatic way of doing it? def sanitize hash new_hash = hash.dup protected_keys = [ :password,…
B Seven
  • 44,484
  • 66
  • 240
  • 385
2
votes
2 answers

Pick up a item according to probability from a hashtable

I'd like to pick up a item according to its given probability from a hashtable. For example, I am storing string "apple" "banana" and "pineapple" into my hashtable. Now I'd like to get a item out of the hashtable according to their given…
J. Ye
  • 73
  • 6
2
votes
1 answer

Hashtable functionality using objects in JavaScript

Okay, I have the following scenario: I get an object, which is an array with lists. There is always 3 items in the array. The items inside the lists, has a specific field I am interested in (ISBN13). I want to build a table like this using…
Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182
2
votes
7 answers

Use a Java hash map even when there is no "mapping"?

I want to store some objects and then be able to retrieve them later as efficiently as possible. I will also remove some of them under certain conditions. It seems a hash map would be the right choice. But, from what I've seen, hash maps always…
2
votes
1 answer

C++ questions about hashtable

I am trying to write a program that uses hashtable in C++. The basic idea is that I have many data points, and I want to use a hashtable so that given a new point, I could know if it already exists or not. But there is some bug in it and I really…
Ming
  • 487
  • 2
  • 7
  • 14
2
votes
8 answers

Remove an Element From HashTable?

I want to remove elements from HashTable, I use hashTable.remove() for this but not getting Hashtable players = new Hashtable(); players.put(1, "Sachin Tendulkar"); players.put(2, "Rahul Dravid"); …
user2932140
2
votes
3 answers

Hashtable raw type

I'm getting this warning here is code: Hashtable nu=new Hashtable(); Hashtable ns=new Hashtable(); nu.put(new String("postmaster"),new String("admin")); ns.put(new String("SMTP"),new String("")); ns.put(new String("POP3"),new…
kamlesh
  • 29
  • 1
  • 2
2
votes
2 answers

OCaml - Save values of recursive function in hashtable

I have this function: let rec som a b acc = if a > b then acc else som (a+1) b (acc+(comb b a));; And what I am trying to do is to save acc value in a hashtable, so my first try was: let rec som a b acc = if a > b then acc else som (a+1) b…
2
votes
1 answer

"Bad permissions for mapped region at address" Valgrind error for a hash table

I'm pretty new to C. When I run the following code for a hash table under Valgrind: table *insertObject (table *h, int pref, char ch) { struct node x; int i; if (ch < 0) { ch=256-ch; } x.chr=ch; x.pref=pref; i…
user2857096
  • 33
  • 1
  • 1
  • 5
2
votes
3 answers

How do hash tables return value in O(1)?

Lets say there is a Hash function. It stores 'n' key-values pair. If i need a value of particular key, is hash function traversing all keys to find the key whose value we are looking for. If yes then how come complexity is O(1)? how do hash looks…
user1322495
  • 79
  • 1
  • 4