Linked Questions

-2 votes
2 answers
1k views

In an interview it was asked from me to show the implementation of hashcode and equals method in an efficient manner so i have constructed the below pojo but the interviewer said that this is not the ...
ndsfd ddsfd's user avatar
0 votes
0 answers
70 views

I have a class Car: public class Car{ final int uniqueId; Car(int id) { uniqueId=id; } } I have to store this as key in a HashMap. The max cars will be 1000. I have ...
user3396729's user avatar
1692 votes
25 answers
308k views

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 ...
bitbonk's user avatar
  • 49.9k
382 votes
12 answers
668k views

Is checking for key existence in HashMap always necessary? I have a HashMap with say a 1000 entries and I am looking at improving the efficiency. If the HashMap is being accessed very frequently, ...
athena's user avatar
  • 5,749
122 votes
3 answers
33k views

The boost::hash_combine template function takes a reference to a hash (called seed) and an object v. According to the docs, it combines seed with the hash of v by seed ^= hash_value(v) + 0x9e3779b9 + (...
Fred Foo's user avatar
  • 365k
100 votes
6 answers
109k views

I need to be able to store a numpy array in a dict for caching purposes. Hash speed is important. The array represents indicies, so while the actual identity of the object is not important, the ...
sapi's user avatar
  • 10.3k
59 votes
5 answers
38k views

I am looking at the implementation of HashMap in Java and am stuck at one point. How is the indexFor function calculated? static int indexFor(int h, int length) { return h & (length-1); } ...
gnreddy's user avatar
  • 2,503
64 votes
3 answers
23k views

To quote from Guidelines and rules for GetHashCode by Eric Lippert: Rule: Consumers of GetHashCode cannot rely upon it being stable over time or across appdomains Suppose you have a Customer ...
Ian Ringrose's user avatar
  • 52.1k
34 votes
5 answers
198k views

I have two java objects that are instantiated from the same class. MyClass myClass1 = new MyClass(); MyClass myClass2 = new MyClass(); If I set both of their properties to the exact same values and ...
Roy Hinkley's user avatar
  • 10.7k
46 votes
3 answers
36k views

I'm wondering what is the best practice for writing #hashCode() method in java. Good description can be found here. Is it that good?
Denys S.'s user avatar
  • 6,563
15 votes
8 answers
82k views

What is the most straightforward way to create a hash table (or associative array...) in Java? My google-fu has turned up a couple examples, but is there a standard way to do this? And is there a ...
akdom's user avatar
  • 33.5k
10 votes
8 answers
14k views

I have a simple custom Point class as follows and I would like to know if my hashCode implemention could be improved or if this is the best it's going to get. public class Point { private final ...
Victor Parmar's user avatar
6 votes
5 answers
10k views

I'm not able to understand on working pattern of HashMap. Kindly help to understand it. Say we have two objects Obj1 and Obj2 having same Hashcode as 1212. Now when we run "==" and equals it returns ...
Pawan Kumar's user avatar
9 votes
2 answers
29k views

The accepted answer in Best implementation for hashCode method gives a seemingly good method for finding Hash Codes. But I'm new to Hash Codes, so I don't quite know what to do. For 1), does it ...
Justin's user avatar
  • 25.7k
20 votes
4 answers
9k views

The Question What is a good specialization of std::hash for use in the third template parameter of std::unordered_map or std::unordered_set for a user defined type for which all member data types ...
Praxeolitic's user avatar
  • 24.4k

15 30 50 per page
1
2 3 4 5