hashtable

Why doesn't my get-method return the assigned value to my key?

烈酒焚心 提交于 2019-12-12 03:43:07
问题 I've been assigned the following task in my Datastructures and Algorithms course, and I have no idea why it does not work. The task is to implement a Linked Hashtable. I have created two classes, one that acts as the key <-> value pair, representing an element (Entry class), and the Hashtable class that has the methods (currently only put and get), but I can't seem any of them to work. The Hashfunction method was provided by our teachers, so I can't answer any questions regarding that.

Convert hash table to byte array

那年仲夏 提交于 2019-12-12 03:36:33
问题 I have a hash table and I want to send it through by Datagram Socket. So to do this I need to have a byte array. How can I convert my hash table to a byte array? I've ignore filling a hash table I've tried do this by this way: Hashtable<String, String> valueNick = new Hashtable<>(); nickStr = valueNick.toString(); byte[] bufferNick = nickStr.getBytes(); for (int i = 0; i < bufferNick.length; i++) { System.out.print(bufferNick[i] + " "); } But nothing has been printed. Thanks very much for any

Uniform hashing functions

拜拜、爱过 提交于 2019-12-12 03:28:51
问题 Hash table basics: - MAJOR TEST COMING UP. ALL HELP WOULD BE APPRECIATED. I am basically a bit confused on uniform hashing of keys. ---------------------- | X X X <=== Chains; X represents an item in there ---------------------- | X X X <=== Multiple X represents collisions ---------------------- | ---------------------- | X X X ---------------------- | X ---------------------- Consider the case of the above hash table where M = 5 (num of rows) and the total length to be 10. How would I know

Segmentation fault 11, python hash with lists, hashing 1 million objects

北城以北 提交于 2019-12-12 03:05:08
问题 When I try to make and hash objects from a file, containing one million songs, I get a weird segmentation error after about 12000 succesfull hashes. Anyone have any idea why this: Segmentation fault: 11 happens when I run the program? I have these classes for hashing the objects: class Node(): def __init__(self, key, value = None): self.key = key self.value = value def __str__(self): return str(self.key) + " : " + str(self.value) class Hashtable(): def __init__(self, hashsize, hashlist =

How to create and populate an array in Powershell based on a dynamic variable?

走远了吗. 提交于 2019-12-12 01:49:44
问题 I've been struggling with this for a couple of days, and I'm not sure how to conquer it. I need to do the following: Import a csv of users with the following values: ID, Name, Region Create an array based on the Region values that I can then use to populate with ID's and Names with that region, ie. Array_SEA AA_SCOM, Adam Andrews, SEA Array_OAK BB_SCOM, Bob Barker, OAK Here's the code I've got right now: $list2 = ipcsv .\TSE_Contact_List.csv | sort-object BU $arraylist =@() foreach ($vitem in

Multi level hash/dictionary creation in C++

别等时光非礼了梦想. 提交于 2019-12-12 01:40:01
问题 I am a bit lost. i have a csv file like the following USN Name DOB Sem Percentage 111 abc 07/03 3 88 112 cde 18/07 4 77 123 ghi 15/11 4 80 I want to create a dictionary kind of structure (multilevel dictionary- Dictionary <string, Dictionary<string, string>> ) using C++. Here i want to store the 1st line as key i.e USN, Name, DOB ... as keys of the hash and the values in that columns as values of the hash. Is it possible? Any help will be greatly appreciated .. Thanks in advance. 回答1: Given

Hash Table Map - updating values

寵の児 提交于 2019-12-12 01:25:41
问题 I am just using a hash table to remember which complementary colours appear in an image. Anyway so I get the current value count: Float count = complementaryColour.get(complementaryString[1] + " and " + colourName); and now I want to change count, so I do: count += (Float)((frequency/width*height)*total_distance); and put it back complementaryColour.put(complementaryString[1] + " and " + colourName, count); Yet sadly it doesn't like this! It says I need to create a float count, and then when

Parse text file and store fields in hash table in Perl

限于喜欢 提交于 2019-12-12 01:09:16
问题 i have a problem with my perl script which read a text file and store the first field separated by a tabulation. Here an example: texte input file : @ ries bibliothèques électroniques à travers tout le 1 0.000012706627117 a a pour les ressortissants des nouveaux états 1 0.000006796917515 a abandonné dès l abord avec dilettantisme l 1 0.000009584625169 a abandonné la culture du lin à fibres 1 0.000009718010335 a abandonné le secteur de la pêche aux 1 0.000006983488644 So the script must store

initialization of flexible array of struct pointers in a struct in c

▼魔方 西西 提交于 2019-12-11 20:31:15
问题 I'm learning hashtable data structures and I want to make a hashtable with a flexible length array of pointers to struct Link (linked list pieces), so that hashtable initialization will set the array to be a length input into the initialization function. At first I was getting the error "flexible array not at the end of struct". When its at the end (as shown) the program crashes (but it still compiles). This is my code: typedef struct Link{ int key; char *name; struct Link *next; } Link;

Double Hashing java

南楼画角 提交于 2019-12-11 19:36:30
问题 public class HashTable <K, V> implements Table<K, V>{ int idx; PairHolder table[]; public HashTable(int size){ table=new PairHolder[size]; } public void put(K key, V value) { int hVal = key.hashCode(); int hashVal = hashFunc1(hVal); int stepSize = hashFunc2(hVal); while(table[index]!=null&&table[index].getFirst() != null){ index += temp; index %=table.length; } table[index].value=value; } public int hashFunc1(int key){ int abs = Math.abs(key%table.length); return abs; } public int hashFunc2