Linked Questions
20 questions linked to/from Quick and Simple Hash Code Combinations
1693 votes
25 answers
308k views
What is the best algorithm for overriding GetHashCode?
In .NET, the GetHashCode method is used in a lot of places throughout the .NET base class libraries. Implementing it properly is especially important to find items quickly in a collection or when ...
429 votes
8 answers
454k views
C++ unordered_map using a custom class type as the key
I am trying to use a custom class as key for an unordered_map, like the following: #include <iostream> #include <algorithm> #include <unordered_map> using namespace std; class ...
22 votes
3 answers
9k views
GetHashCode() for OrdinalIgnoreCase-dependent string classes
public class Address{ public string ContactName {get; private set;} public string Company {get; private set;} //... public string Zip {get; private set;} } I'd like to implement a ...
25 votes
4 answers
17k views
How to combine hash codes in in Python3?
I am more familiar with the "Java way" of building complex / combined hash codes from superclasses in subclasses. Is there a better / different / preferred way in Python 3? (I cannot find anything ...
20 votes
4 answers
18k views
C# List as Dictionary key
I have a dictionary which is keyed by a List: private Dictionary<List<custom_obj>, string> Lookup; I'm trying to use ContainsKey, but it doesn't seem to be working, and I have no idea why....
7 votes
3 answers
13k views
How can I make a hashcode for a custom data structure?
I've made a custom "Coordinate" data structure which defines the position of an object according to a certain system. A coordinate is defined as follows: public class Coordinate { public int X; ...
7 votes
3 answers
5k views
Why can't I return arbitrary array of string?
The compiler allows me to do the following: procedure MyProc(const ADynData: array of string); or procedure MyProc(const ADynData: TStringDynArray); and pass arbitrary data like so: MyProc(['Data1',...
5 votes
2 answers
9k views
HashCode equivalent in .Net Framework
In converting .NET Core project to .NET Framework, one thing notice is using Hashcode now needs to be converted something equivalent. As can be read, Hashcode is specific to .NET core versions and ...
6 votes
2 answers
5k views
Use objects as keys in TObjectDictionary
When I use TObjectDictionary, where TKey is object, my application work uncorrectly. I have two units, thats contain two classes. First unit: unit RubTerm; interface type TRubTerm = Class(...
10 votes
4 answers
1k views
C# .NET GetHashCode function question
Hi I have a class with 6 string properties. A unique object will have different values for atleast one of these fields To implement IEqualityComparer's GetHashCode function, I am concatenating all 6 ...
8 votes
2 answers
2k views
TDictionary Hashing is broken for records of strings
This reproduces the problem : program Project1; {$APPTYPE CONSOLE} uses Generics.Collections; type TStringRec = record s1 : string; s2 : string; end; TGetHash<TKey,TValue> = ...
1 vote
2 answers
2k views
Most efficient way to generate a mesh's string-hash in unity/c#?
As part of my current project, I need to generate hashes for meshes in Unity. These are used to later check whether the mesh content has changed. Due to interface considerations, the hash ...
0 votes
3 answers
627 views
Fast way to remove duplicates with the same content ( custom .equals() ) from list
So I searched for this "problem" and only came accross questions asking how to remove real duplicates from a list. But what I want is to remove every Object being equal to another Object in the list ...
1 vote
3 answers
244 views
Speed Up Performance - LINQ to get items in one LIST, that are not in another List
I have two lists and I'm trying to return items that are not in the other list. Here is my code: var Results = ListOne.Where(x => ListTwo.All(a => a.EmployeeNum != x.EmployeeNum && a....
0 votes
1 answer
880 views
Alternative to hashing for quick comparison to avoid conflicts
I'm implementing a caching table to avoid having to perform a costly operation that creates a generic object from a set of parameters describing it. Once an object is requested, an hash of these ...