hashtable

Pointer problem with HashTable insertion and lookup

一笑奈何 提交于 2019-12-11 18:32:26
问题 I'm using a custom C implementation of data structures from github. Documentation here: http://fragglet.github.io/c-algorithms/doc/ It's my first time with this low level HashTable usage and I'm getting some pointer problems when I recover the values that I previously inserted. My code is just a simple test with just the necessary to insert and recover data. #include "list.h" #include "hash-table.h" #include <stdio.h> //typedef unsigned int (*HashTableHashFunc)(HashTableKey value); unsigned

Sorting a hash table in Racket

心已入冬 提交于 2019-12-11 17:36:29
问题 I'm new to Racket and I'm trying to define a function sort-mail that is gonna sort a hash table. I've some defined lists: (define test-dates '("Sun, 10 Sep 2017 09:48:44 +0200" "Wed, 13 Sep 2017 17:51:05 +0000" "Sun, 10 Sep 2017 13:16:19 +0200" "Tue, 17 Nov 2009 18:21:38 -0500" "Wed, 13 Sep 2017 10:40:47 -0700" "Thu, 14 Sep 2017 12:03:35 -0700" "Wed, 18 Nov 2009 02:22:12 -0800" "Sat, 09 Sep 2017 13:40:18 -0700" "Tue, 26 Oct 2010 15:11:06 +0200" "Tue, 17 Nov 2009 18:04:31 -0800" "Mon, 17 Oct

Why this code doesn't allocate memory in C?

徘徊边缘 提交于 2019-12-11 17:24:51
问题 Updated question is here Memory allocation problem in HashTable 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, "world"); HashTable.c HashTablePtr createHashTable(unsigned int capacity){ HashTablePtr hash; hash = (HashTablePtr) malloc(sizeof(HashTablePtr)); hash->size = 0; hash->capacity = capacity; ListPtr mylist = (ListPtr)calloc

How to implement a robust hash table like v8

时光怂恿深爱的人放手 提交于 2019-12-11 16:33:34
问题 Looking to learn how to implement a hash table in a decent way in JavaScript. I would like for it to be able to: Efficiently resolve collisions , Be space efficient , and Be unbounded in size (at least in principle, like v8 objects are, up to the size of the system memory). From my research and help from SO, there are many ways to resolve collisions in hash tables. The way v8 does it is Quadratic probing: hash-table.h The wikipedia algorithm implementing quadratic probing in JavaScript looks

How do I remove duplicates from a datatable altogether based on a column's value?

北城以北 提交于 2019-12-11 16:05:34
问题 I have 3 columns in a DataTable Id Name Count 1 James 4345 2 Kristen 89231 3 James 599 4 Suneel 317113 I need rows 1 and 3 gone, and the new datatable returning only rows 2 and 4. I found a really good related question in the suggestions on SO--this guy. But his solution uses hashtables, and only eliminates row 3, not both 1 and 3. Help! 回答1: I tried this Remove duplicates from a datatable.. using System.Data; using System.Linq; ... //assuming 'ds' is your DataSet //and that ds has only one

How v8 hashes the keys in a hash table

核能气质少年 提交于 2019-12-11 15:26:46
问题 In learning how to implement a robust hash table, I am wondering the algorithm v8 uses to create the hash from a key, and what they use as the key (for string keys). Most of the examples on hash table key generation are hello world examples and subject to collision attacks and other things. I am looking for an example of how a production system implements a hash table, such as v8. Looking through the v8 source has been helpful, but it is a bit over my head. 回答1: V8's string hashing

std::unordered_map containing another std::unordered_map?

烈酒焚心 提交于 2019-12-11 14:52:27
问题 We are working on a game project for school in c++. I'm in charge of the map object, who will contain Entities like bombs, players, walls and boxes. I have 3 containers in my map: A std::list for players (multiple players can stand on a same case). A std::unordered_map<int, std::unordered_map<int, AEntity*> > for walls. An other std::unordered_map<int, std::unordered_map<int, AEntity*> > for bombs+boxes. The aim is to access an Entity very fast on the map, number of entities can be very high.

Powershell -match in function - gets extra true/false when returned

♀尐吖头ヾ 提交于 2019-12-11 13:08:00
问题 Why do I get the extract "True" or "False" (when all I want to get back is just the zip code) on the result of this function: Function GetZipCodeFromKeyword([String] $keyword) { $pattern = "\d{5}" $keyword -match $pattern $returnZipcode = "ERROR" #Write-Host "GetZipCodeFromKeyword RegEx `$Matches.Count=$($Matches.Count)" if ($Matches.Count -gt 0) { $returnZipcode = $Matches[0] } Write-Host "`$returnZipcode=$returnZipcode" return $returnZipcode } cls $testKeyword = "Somewhere in 77562 Texas "

MAD method compression function

故事扮演 提交于 2019-12-11 12:48:52
问题 I ran across the question below in an old exam. My answers just feels a bit short and inadequate. Any extra ideas I can look into or reasons I have overlooked would be great. Thanx Consider the MAD method compression function, mapping an object with hash code i to element [(3i + 7)mod9027]mod6000 of the 6000-element bucket array. Explain why this is a poor choice of compression function, and how it could be improved. I basically just say that the function could be improved by changing the

How I display the content of my hash table in java

谁都会走 提交于 2019-12-11 11:17:40
问题 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 MyHashDrivergood{ private static String fileName = ""; private static int choice = 0; private int initialCapacity = 0; private static String[] testData = null; public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); MyHashTableTable<String, String