Menu
  • HOME
  • TAGS

Array Insert Time Jump

php,arrays,hashtable

While I would suggest double checking my answer on the PHP internals list, I believe the answer lay in zend_hash_do_resize(). When more elements are needed in the hash table, this function is called and the extant hash table is doubled in size. Since the table starts life at 1024, this...

ostream operator<< not working properly

c++,arrays,printing,hashtable,ostream

There is a logic error in the function Customer::getHash. That may not solve your problem but it should be fixed anyway. int Customer::getHash(int hash) { string key = getLastname(); cout<<"key: "<<key<<endl; // getFirstname(); // getID(); int i = 0; // int j = 0; // int k = 0; for...

Why are HashTable order different in Visual Studio Debugging compared to IIS

c#,hashtable

As @usr helped me find out, the reason for this behaviour lies in the GetHashCode() function, which is used as the base for the HashTables keys. Depending on the key, the order of Iteration over a HashTable will be different. A hash function should normally return the same hash vor...

Insert key value to HashTable when value is an ArrayList

java,hashtable

Is there any way to add elements to the Arraylist (value) one by one rather than one time with put. One can't add anything to the ArrayList by put(...), but by add() If you want to add value one by one to the ArrayList you may use foreach loop:...

F#: How to identify keys that have multiple values in a HashTable?

f#,hashmap,hashtable

Hashtable doesn't support multiple values for the same key - you'll get an exception when you try to add a second entry with the same key. It is also untyped, you should almost always prefer a typed mutable System.Collections.Generic.Dictionary or an immutable F# Map. What you're looking for is a...

Merge Sorting HashTable pairs based on String key

java,sorting,hashtable

When you create a new HashTable with sortedData as a parameter they will not be in order. HashTables are used for efficiency not sorting. When elements are added they are hashed into the table in basically random order. Find a different way to hold the sorted data than a HashTable....

Is mod prime good enough as a hash function for a hashtable in C

c,hashtable,hash-function

The right hash function boils down to the data you are hashing: how random are your values? If your values are uniformly distributed over the range, and the range is much larger than the number of hash buckets, then just using value MOD number_of_buckets will be a reasonable hash function...

How do I Print a Hash Table in C?

c,hashtable,stdout

As requested in the comments, a search function as desired would look like this: int search(const char* key, int* out_val) { // Find the hash index into the table. const int index = hash(key); // Now do a linear search through the linked list. for (struct entry* node = table[index];...

Python Hash: Insert Method

python,hash,insert,hashtable

Okay, we'll have to go from first principles here. Here's what insert will need to do for your case: Get an initial slot number based on the key by calling hash_function. Save this slot position for later, we'll need it to detect if the hash table is full. Check the...

java - how to create custom hashtable iterator?

java,iterator,hashmap,hashtable,inner-classes

Generally speaking, yes, it would probably be better if you did provide an iterator that iterates over HashEntrys, so users get both the key and value (and state) when iterating. Oftentimes the value will not make sense without the key, and vice versa. Why don't you just make the HashEntry...

Is there a difference between an array of Linked Lists and a Hash table?

arrays,linked-list,hashtable

With a hash table you insert a value V into a table with a key K. This K can be anything that can be processed by a hash function. Insertion into SList[], however, must be done using an integer index, which is far less flexible than being able to use...

Hash tables, same record on each hash table cell

c,hashtable

hash[(hash1+j*hash2)%m] = word; That just assigns the address of word to the hash entry. Which is always the same. And at the end of the loop the contents of word is obviously going to be the last thing that was read by fscanf. SO you need something like: hash[(hash1+j*hash2)%m] =...

Modify value when getting value of key from a hashtable in PowerShell

powershell,hashtable

You can probably do something like this: $Selector = $Structure $Structure = @{ "KeyOne" = "Value" "KeyTwo" = "$($Selector.Change.This.That)" "KeyThree" = "$($Selector.Change.This.Thing) with Stuff" "Change" = @{ "This" = @{ "That" = "Another Value" "Thing" = "Yogurt" } } } $Structure["KeyThree"] ...

Hashtable key syntax to refer to embedded hashtable element

powershell,hashmap,hashtable,powershell-v2.0

A couple things: You need to fix the regular expression to actually match the nested properties. Right now it doesn't you need it to be __(?<tokenName>[\w\.]+)__ Use Invoke-Expression to dynamically expand the nested properties. Just build a string the represents the expression you want to evaluate. This is good because...

foreach items in hashtable

c#,hashtable

Hashtable has DictionaryEntry as collection element foreach (DictionaryEntry entry in toboofer) { // do something } Make list of myclass from hashtable: var listOfMyClass = toboofer.Cast<DictionaryEntry>(). Select(e => new myclass() { Fio = e.Key.ToString(), About = e.Value.ToString() }); ...

Null Pointer Exception with Singly Linked List to hashtable Java

java,arraylist,set,hashtable

This line isn't doing what you think it's doing. hashArray = new SLL[size]; You need to actually create each SLL that will populate the array once the array itself is created....

How to access actual internal factor lookup hashtable in R

r,hashtable,level,r-factor

I think you either want the indexes which map the elements of the factor to elements of the factor levels, as in: vec <- c('a','b','c','b','a') f <- factor(vec) f #> [1] a b c b a #> Levels: a b c indx <- (f) attributes(indx) <- NULL indx #> [1]...

csv parsing and manipulation using python

python-2.7,csv,pandas,hashtable

I'm unsure what you mean by "count the column". An easy way to read the data in would use pandas, which was designed for just this sort of manipulation. This creates a pandas DataFrame from your data using the first row as titles. In [374]: import pandas as pd In...

How to check that every value in a hash-table satisfies a predicate in Common Lisp

common-lisp,hashtable

You'd like to know how you do what every does with sequences, with hash tables. You can use the loop macro to iterate over every value and use :always to check each element for your test. As with every :always will terminate the loop immediately when the test is NIL....

Can we put hash tables inside a hash table?

java,hashtable,spreadsheet

How about Map<String, Map<Integer,Integer>> asdf = new HashMap<String, Map<Integer, Integer>>(); But to be honest you should start with wrapping it inside an object. In this structure globally will be very inconvenient. You could try this BiHashMap public class BiHashMap<K1, K2, V> { private final Map<K1, Map<K2, V>> mMap; public BiHashMap()...

Hash table with string check

c++,hashtable

That's not a hashtable. The hash variable is an array of int that's indexed by the ascii code of the char in the string, so hash[s[i]] where s[i]=='A' is hash[63]. So, what it does is storing the characters' position in an array indexed by the character code. hash[s[i]]!=-1 checks if...

Perl hash substitution with special characters in keys

regex,perl,hashtable,substitution,string-substitution

Problem 1 You use the pattern a* thinking it will match only a*, but a* means "0 or more a". You can use quotemeta to convert text into a regex pattern that matches that text. Replace my $keys = join '|', keys %stimhash; with my $keys = join '|', map...

Hashtable returning null but object key is present

java,hashtable

I think the problem is in the Pair method. When you do this: this.rates.get(new Pair(from, to)); you are creating a new instance of Pair, which is not the same as the one you've put into the map in the addRate method. If you want the code to work correctly, you...

How can I send a hashtable to my clientsocket?

java,sockets,hashtable

Since Hashtable implements the java.io.Serializable interface, you can serialize the object and send it over the socket's output stream: Hashtable table = new Hashtable(); // TODO: avoid raw types ... ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); oos.writeObject(table); oos.close(); To read the object in the client, you need to use an ObjectInputStream:...

How do you use a 'just-defined' hash value in your next hash value

ruby,hash,hashtable

One way is to use a temp variable: h = { a: x = 5, b: x + 1 } ...

Reference as key in swift dictionary

swift,dictionary,key,hashtable,memory-address

You could use /// Return an UnsafePointer to the storage used for `object`. There's /// not much you can do with this other than use it to identify the /// object func unsafeAddressOf(object: AnyObject) -> UnsafePointer<Void> to implement a hash value, and the identity operator === to implement the Equatable...

hashtable that change value by itself

java,dictionary,hashtable

From the comments: yes i have, actually, there are several Symbol that can be equal A quick demonstration of the problem: public static void main(String[] args) throws Exception { final AtomicInteger a = new AtomicInteger(0); System.out.printf("a:%s%n",a); final AtomicInteger b = a; System.out.printf("a:%s.b:%s%n", a, b); a.set(10); System.out.printf("a:%s.b:%s%n", a, b); b.set(5); System.out.printf("a:%s.b:%s%n",...

In handling hash collisions, why use a linked list over a BST?

data-structures,hashmap,hashtable

The justification of a hash table is that there should be very few items hashing to the same hash slot. For these small numbers, a linked list should actually be faster than the BST (better constant factors) and will in any case be simpler and more reliable to code. The...

How to parse Hashtable / ArrayList [duplicate]

c#,serialization,arraylist,deserialization,hashtable

The following answer should be flagged with "maybe" as it is really hard to see whats behind your given code. Usually a DictionaryEntry provides a structure with Key and Value. But in your case this isn't even needed as your ArrayList contains just "Sub-Lists". So if I understand you correctly...

how to get RadioButtons Id using HashTable and Key from HasTable

java,android,hashtable

You can get Key from hashmap use Key.set() for more information look on this link Java Doc Example Set<String> keys = h.keySet(); // Loop over String keys. for (String key : keys) { System.out.println(key); } can u please tell me for which purpose you are getting RadioButtons id ? After...

Why is Python's hash function treated as a sort function on some sequence of numbers?

python,python-2.7,python-3.x,hashtable

Although there are a lot of questions in SO about hash and its order,but no one of them explains the algorithm of hash function. So all you need here is know that how python calculate the indices in hash table. If you go through the hashtable.c file in CPython source...

Search HashTable not by unique key

c,data-structures,hashtable,glib

First of all, you are getting a NULL because you are looking for a struct, not a key. Instead of: my_data = ((my_struct*)(g_hash_table_lookup(my_hashtable, my_key))); Use my_data = ((my_struct*)(g_hash_table_lookup(my_hashtable, my_key->key))); Or my_data = ((my_struct*)(g_hash_table_lookup(my_hashtable, 0))); Anyway, looks like you want a three data value as key (key, field1 and field2), so...

Format a nested hashtable

powershell,hashtable

You need to expand nested hashtables yourself: $items | Format-Table Name, @{n='Value';e={ if ($_.Value -is [Hashtable]) { $ht = $_.Value $a = $ht.keys | sort | % { '{0}={1}' -f $_, $ht[$_] } '{{{0}}}' -f ($a -join ', ') } else { $_.Value } }} ...

Why are nested dictionaries OK but nested sets forbidden?

python,dictionary,set,hashtable

The problem is that your examples aren't alike. There is no restriction on the values of a dictionary, only on the keys. Here is a more accurate comparison: >>> d = {{'a': 'b'}: 'c'} Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> d = {{'a': 'b'}: 'c'}...

Retrieve Custom Object From Hashtable

powershell,hashtable

There are uses for GetEnumerator(), but in your case you're better off just looping over the keys of the hashtable: $hashWrite.Keys | % { $hashWrite[$_].Wipe } | select -Expand FullName ...

Hash table - implementing with Binary Search Tree

data-structures,hashtable,binary-search-tree

The full text of that section states, with the last paragraph being the one you asked about: A hash table is a data structure that maps keys to values for highly efficient lookup. In a very simple implementation of a hash table, the hash table has an underlying array and...

Holding information in hashtables or arrays then outputting

c#,checkbox,hashtable

If you use an array, it implies you will have to create entries for each text box as per your example. Out of preference I would probably use a dictionary<string,string> where the key is the control name. Then, my textbox value could be: txtProblem1.text = dictionary.ContainsKey(txtProblem1.Name) ? dictionary[txtProblem1.Name] : "";...

How to find the keys of the largest values in Hash R?

r,hash,max,hashtable

Full disclosure: I authored and maintain the hash package. Unless you have a hash with many key-value pairs and need the performance, standard R vectors with names will likely be a better solution. Here is one example: v <- c(a = 5, b = 2, c = 3, d =...

Why is the cost of a hash lookup O(1) when evaluating the hash function might take more time than that?

hash,hashtable,big-o,time-complexity

When talking about hashing, we usually measure the performance of a hash table by talking about the expected number of probes that we need to make when searching for an element in the table. In most hashing setups, we can prove that the expected number of probes is O(1). Usually,...

String-Object mismatch for hashlist in java

java,hashtable,type-mismatch

Because argument passed to printmap is of type Hashtable<String,Course> hashlist, Whereas in main you declared private static Hashtable hashlist2; hashlist2 = new Hashtable(); which is non-generic version(That's why when you iterate in for-loop you get object instead of String), you can fix it by private static Hashtable<String,Course> hashlist2;

When to use hash data structure?

c,performance,algorithm,hashtable,avl-tree

Below are some of the benefits of Hash structures, Fast lookup (O(1) theoretically) Efficient storage (helps to store key-value) Though these properties are beneficial but in some scenarios hash table can underperform. If you have large amount of objects then more storage space (Memory) will be required and thus can...

Why hashTable contains redundant Keys

java,hashtable,containskey

This line is the problem: result = prime * result + ((ch == null) ? 0 : ch.hashCode() This is the hashcode of the array not the hashcode of the content of the array, hence when you say: double[] ary = {1.5}; double[] ary3 = {1.5}; it is different besides...

Hash Table With Chaining Search Time?

linked-list,hashtable

This is a misunderstanding of O(n) time. Big-O analysis has to do with the general case, not a specific instance. Intuitively, think of your hash table doing thousands or millions of lookups over time and taking a step back and judging if it's doing what a hash table is supposed...

What collection to use in java for storing multiple objects that have the same hashcode?

java,hashtable

Addressing the general issue of hashcodes first. Hash tables in general work will still work if you have many distinct keys that map to the same hashcode. However, hash tables are 1-to-1 maps. They map each distinct key to one (and only) records / entry. In the Java context, this...

Hashing with chaining and use table of size `m`

algorithm,data-structures,hash,hashmap,hashtable

You can empirically check it with a simple code: int[] mVals = {11, 7, 9, 12}; for (int m : mVals) { int[] cells = new int[m]; for (int i = 1; i<= 100; i++) { int x = i*i % m; cells[x]++; } System.out.println("m=" + m + " cells="...

How can I use different definition of class for different template type in C++? (Class Overloading?)

c++,templates,hashtable,overloading

"But I've never heard of "Class Overloading". What is the right way to solve this problem do you think?" You might use a template class and specializations (overloads) for it's interface: template<typename T> class hash_table { public: bool probe(const T& x); hash_table<T> chain(const T& x); }; template<> bool hash_table<int>::probe(const...

Why is value comparison in hashtable returning false even when the values are the same?

c#,hashtable

The Hashtable class is not generic; it just contains Objects, not a specific type. When you do this: if (uniqueChars1[key] != uniqueChars2[key]) the compile-time type of uniqueChars[key] is Object, not Int32. So you're using the Object implementation of the inequality operator, which just compares references. Since Int32 is a value...

Key Names With @ Symbol

rest,powershell,hashtable

Having a key name start with @ is no problem if your key names are in quotes: PS C:\> @' >> { >> "@foo" : 42 >> } >> '@ | ConvertFrom-Json | Format-Table -AutoSize >> @foo ---- 42 Same if you define a hashtable in PowerShell: PS C:\> $ht...

Perl substitution - lookup table issue

regex,perl,hashtable,lookup,substitution

Main problem was mentioned already in @ahjohnston25's answer, but you took over so ugly code with evaling and fuzzy stuff, so I made it a bit simpler and cleaner: #!/usr/bin/perl use strict; use warnings; use autodie; my %repl = ( "kml1" => "Area A", "kml12" => "Area B", "kml123" =>...

How do I keep load factor small in my hash table?

data-structures,hashtable,quadratic-probing

The implication is that at some point (when you would exceed a load factor of 0.5 in this case), you'll have to allocate a new table (which is bigger by some factor, maybe 1.5 or 2, and then rounded up to the nearest prime number) and copy all the elements...

Adding Strings to ArrayList> Java

java,string,list,arraylist,hashtable

ensureCapacity() may resize the backing array of the ArrayList, but is doesn't change the number of elements actually stored in the List. Therefore, it doesn't affect the return value of table.size(). table.get(index) will return null unless you add at least index+ elements to your list. It looks like you are...

Using a hashtable to replace values characters within an array

java,hashtable

public void swapCharactersAndPrint(String[] data, Map<Character, Character> replacements) { for (String string : data) { for (char c : string.toCharArray()) { if (replacements.containsKey(c)) System.out.print(replacements.get(c)); else System.out.print(c); } System.out.println(); } } ...

Modifying Key in hash table?

powershell,hashtable

No, you cannot do this directly. Instead, you will need to make a new key that has the same value as "Tree" and then delete the "Tree" key when you are done. Below is a demonstration: PS > $names = @{Tree = "1"; Forest = "2"} PS > $names.NewKey =...

Chain Hash Table: Insert function

python,hash,insert,hashtable

This does what you say you want: def insert(self, key): slot = self.hash_function(key) if key in self.slots[slot]: return -1 else: self.slots[slot].append(key) return slot ...

[C#]which is faster between Sqlite and dictionary?

c#,database,sqlite,hashtable

If I were you I'd write an interface containing all methods required to store and retrieve this information, then create an implementation of that interface that is most straightforward to write. Once you find that this part of your application is the bottleneck, replace the implementation of the interface with...

Implemetning Tree with Map

java,algorithm,data-structures,hashtable,binary-tree

It looks like you are trying to "fold" adjacency lists into a single hash table. That's possible, but you need to change the type of the element to something capable of holding two integers. The most common approach would be using a TreeNode class: class TreeNode { private final int...

Linear probing using Hashtable [closed]

java,hashtable,linear,probing

What is it used for? It is used for open-addressed hashing, i.e. memory efficient set and map/dictionary behavior. What does it do? Defines an algorithm for deciding where to store and find members of a set, or where to store and find keys and values of a map. Which...

Retrieving hashmap values in XSLT

java,xslt,hashtable

As you defined- HashMap<String,String>() its keys and values must be String.While You are passing $rollNumber as a variable type on retrieving data. <xsl:variable name="addressData" select="map:get($mapData,$rollNumber)"/> you have to cast it into String from variable before passing. <xsl:variable name="addressData" select="map:get($mapData,(String)$rollNumber)"/> ...

Should I cast size_t to ptrdiff_t?

c,pointers,hashtable,ptrdiff-t

No need for ptrdiff_t here as there is no pointer difference around. What you probably want is: for (node_t ** tc = table; tc < (table + tableSize); ++tc) { ... } ...

Nested Internal Class with Readonly Hashtable throws Null ref exception.. on assignment

c#,design-patterns,compiler-errors,hashtable,nullreferenceexception

Indeed you need to instantiate the _privateReadonlyHashTable field. internal class GamerTags { private readonly Hashtable _privateReadonlyHashTable = new Hashtable(); .. .. } ...

Is it possible to create a Map where every Key points to the same Value?

java,hashtable

I suppose the most reasonable way to do this with existing API is like the following: new TreeMap<K, V>(new Comparator<K>() { @Override public int compare(K lhs, K rhs) { return 0; } }); This TreeMap considers all keys equal but will otherwise maintain pretty good Map semantics. Note that the...

how can I implement the constructor of a hashtable in java

java,hashmap,hashtable

In Java List is just an interface which cannot be instantiated. What you need is a class implementing such interface, for example, ArrayList. Try buckets = new List[120]; for(int i=0;i<120;i++) { buckets[i]=new ArrayList<String>(); } ...

Very simple hash table inquisition

c,data,structure,hashtable

No, your understanding of % (modulo) is incorrect. Specifically you seem to ignore the reason for the right-hand argument, and assume it's always a constant 10 which is simply false. The expression x % y will return a value in the range 0 to (y - 1), inclusive (assuming both...

Adding a new element to an array in a hash of arrays

perl,data-structures,hashtable,associative-array,perl-data-structures

I think that my @element = split(' ', $element); if ($file =~ m/$element[0]/) { push @{$all_samples{$element}}, $file; } Is not doing the right thing, so $all_samples{$element}} is a new arrayref. You're printing six one element arrays rather than three two element arrays. But then it doesn't help that you're printing...

Hashtable content : the first 2 Keys are Null … How to get my saved content

java,hashtable

You should run your program through a debugger to better understand what it is doing. Let's follow an example: Hashtable<String, String> myHashtable = new Hashtable<>(); myHashtable.put("1", "rat"); myHashtable.put("2", "cat"); myHashtable.put("3", "bat"); Running your loop, the first iteration will go like this: myHashtable.keySet().toString() -> "[3, 2, 1]" String[] key = myHashtable.keySet().toString().split(",...

Add words frequency to Hashtable

java,hashtable

Set<String> keys = table.keySet(); for (String count : keys) { if (table.containsKey(count)) { table.put(count, table.get(count) + 1); } else { table.put(count, 1); } } Right now, you're incrementing the keys that are already in the map. Instead, I don't think you want to loop over anything, you just want to...

Output( ) from a Set class with Singly Linked List Hash Table

java,set,hashtable,singly-linked-list

You need to iterate through the entries in your hash array, and for each non-null entry, iterate through the linked list: public void output() { for (int i = 0; i < hashArray.length; i++) { if (hahArray[i] != null) { hashArray[i].outputList(); } } } ...

Read a HashMap in App Script

javascript,google-apps-script,hashtable

Based on your code it appears you are pushing an Object onto an Array, but you attempt to access the object properties directly on the Array, rather than on the element in the Array. You'll first need to access the correct Array element, before attempting to access your object properties:...

How does hopscotch hashing actually work?

algorithm,performance,hash,hashtable,hopscotch-hashing

It says find an item whose hash value lies between i and j, but within H-1 of j. It doesn't say find an item whose current location lies between i and j, but within H-1 of j. The d at index 3 has a hash value of 1, which doesn't...

C Memory Management -> Hash

c,algorithm,hash,hashtable

Your malloc is not necessary the reason why that wasn't obvious is because it was hidden by the way you typedefd the HashTable, don't ever do that, the following code works as you expected yours to do #include <stdio.h> #include <stdlib.h> #include <string.h> #define HASHSIZE 31 #define EMPTY "" #define...

`[]': can't convert String into Integer (TypeError)

ruby,arrays,hashtable

The hash object is inside an array. You need to fetch the hash object first (sheets[0]), then you can use key to fetch the item you want: sheets = [{"id"=>3, "subject"=>"www", "body"=>"www", "target_groups"=>"www", 0=>3, 1=>"www", 2=>"www", 3=>"www"}] sheets[0]["subject"] # => "www" ...

Powershell V4 - Passing Hashtable to Function

powershell,hashtable

Short Answer: No I can't see any reason why it would be bad practice to use a [hashtable] or any other data type as a parameter, at least in a vacuum. If you gave us some idea of what you intended to do with it, then we may be able...

Powershell output contents of hash to file

powershell,hashtable

If you want it in the same format it displays on the screen (folded at the pipes for readability): $h.getenumerator() | sort value -descending | format-table | out-string | Add-Content D:\Script\iis_stats.log ...

issues with trying to add an item to a linked list

c,linked-list,hashtable

There are multiple problems in your code. It is hard to fix them all at the same time. Basically you aren't implementing linked lists properly. Here are some major problems. In the collision case of insert you are creating two new nodes, chaining a dummy one before the head and...

F#: Converting tuples into a hashtable

f#,hashmap,hashtable

The easies way is to use dict It will convert a sequence of tuples in a Dictionary which is a string type Hashtable. > dict [(1,"one"); (2,"two"); ] ;; val it : System.Collections.Generic.IDictionary<int,string> = seq [[1, one] {Key = 1; Value = "one";}; [2, two] {Key = 2; Value =...

java, JSTL and getting values by key

java,foreach,jstl,hashtable

You should be using variable name assigned to varStatus - 'cipher_loop' and not varStatus itself. Also you should use the index property or the count property to get the current index. (index starts at 0 and count at 1 by default) ${missing_ciphers[varStatus]} should be ${missing_ciphers[cipher_loop.count]} Edit What is the type...

hashtable.get not working - java

java,hashtable

You need to look at the .equals() method for your PhoneNum class. Hash uses equals() to determine whether a key is equal to the parameter from get(). Note that, if you write an equals() for your PhoneNum, you ALSO need to write a PROPER hashcode(), so it is not just...

Optimized loading to a hashtable in C#

c#,mobile,hashtable

Flat files aren't used for a reason -- processing them is linear at best (and your case worse because you read them all, then split each one (already O(n^2) at worst), then sort them (another O(nlogn)) to insert into a hash table. You'd be much better off with a DBMS,...

nim two key table with generics

generics,hashtable,nim,nimrod

Looks a lot like a bug to me, I reported it: https://github.com/Araq/Nim/issues/2722 As a workaround it works when TwoKeyTable is not generic: import Tables type TwoKeyTable = Table[string, Table[string, int]] # initialize two key table proc initTwoKeyTable(): TwoKeyTable = result = initTable[string, Table[string, int]]() # check to see if keys...

Serialize hashtable using Json.Net

c#,json,json.net,hashtable

The problem is that the System.Collections.Hashtable isn't strongly typed - it will hold any type of object, and JSON.NET is most likely serialising the string representation of your hashtable contents. Before you spend too much time massaging the JSON.NET serializer/deserializer to compensate for this, you might want to consider switching...

Removing a node from a LinkedList (C#)

c#,data-structures,linked-list,hashtable

You'll want to loop through the list until the next node is the one you want to delete. Then set the current to the next nodes next node. public void Delete(string value) { if (head == null) return; if (head.Value == value) { head = head.Next; return; } var n...

Convert Hashtable Values In-Place

string,powershell,hashtable,powershell-v2.0

I don't think there's a "more efficient" way of changing the values. You can set the values of each key to a value of a new type ($hash[$key] = $hash[$key].ToString()) but this is complicated if you're looping because you're changing the object being enumerated. You can get around this in...

Identifying keys with multiple values in a hash table

python,csv,hashtable

Here are a few concepts you should learn and understand first: Importing and Exporting CSV: https://docs.python.org/2/library/csv.html Counter: https://docs.python.org/2/library/collections.html#collections.Counter or Defaultdict(int) for counting: https://docs.python.org/2/library/collections.html#collections.defaultdict It sounds like you need column1 to be the key of a dictionary. If you're trying to count how many times it appears (that's not clear), then...

Implementing a hash table that maps strings to an array in C++. I keep getting “Debug Assertion Failed” and I don't know why

c++,hash,hashmap,hashtable,hash-function

Your problem is here: HashTable::~HashTable() //destructor { for(unsigned int i=0;i<arrSize;i++) arr[i].deleteList(); delete arr; } you are calling delete arr, but you allocated arr with new[]. You need to call: delete[] arr; ...

Hash function for strings without respecting char's position

algorithm,hash,hashtable

If the representation of a hand is similar to a bit set, it is already unordered. For example, if you use a combination of bit masks to represent a combination of cards, say, like this A♠ - 0x00000001 2♠ - 0x00000002 3♠ - 0x00000004 4♠ - 0x00000008 ... K♠ -...

Why don't we use AVL tree for hash table's item storage?

data-structures,hashtable,avl-tree

This is discussed directly in the Wikipedia article your referenced: Separate chaining with other structures Instead of a list, one can use any other data structure that supports the required operations. For example, by using a self-balancing tree, the theoretical worst-case time of common hash table operations (insertion, deletion, lookup)...

Use hashtable as parameter when splatting?

powershell,hashtable,start-job

You will need to pass the variable into the scriptblock as a parameter of the scriptblock, and then splat that parameter to your second script. Something like this should work for you: Start-Job -Name "MyJob" -ScriptBlock {Param($PassedArgs);& "C:\myscript.ps1" @PassedArgs} -ArgumentList $Arguments I created the following script and saved it to...

What is the runtime for quadratic probing in a HashTable?

hash,hashmap,runtime,hashtable,hashset

If there are n - 1 occupied buckets in your hash table, then regardless of the sequence in which you check for an empty bucket, you cannot rule out the possibility that you will need to test n buckets before finding an empty one. The worst case for quadratic probing...

how to create a linked-list in a hash-table with the specific index?

java,linked-list,hashtable,collision

Here is how Java HashMap does it internally: class Entry<K,V> implements Map.Entry<K,V> { final K key; V value; Entry<K,V> next; int hash; /** * Creates new entry. */ Entry(int h, K k, V v, Entry<K,V> n) { value = v; next = n; key = k; hash = h; }...

Get all keys from (search.h) hash search table

c,hashtable

There is no standard functionality of iterating through the entries of the hash table. This question is addressed here (in the hdestroy section): It is important to remember that the elements contained in the hashing table at the time hdestroy is called are not freed by this function. It is...