Questions tagged [hash-code-uniqueness]

Use this tag for questions related to a Hash Code's Uniqueness, i.e. when the hash codes are unique.

is used in its general meaning, so you are advised to use one or more additional tags to best describe your specific case.

45 questions
1
vote
3 answers

Accuracy of a Set with a HashMap backing's contains() method?

Hi I'm using a Set backed by a HashMap to keep track of what edges I have already traversed in a graph. I was planning on keying the set by the result of adding the hashcodes of the data stored in each edge. v.getData().hashCode() +…
Ethan
  • 1,206
  • 3
  • 21
  • 39
0
votes
4 answers

Hashcode value for Map Entry

As per javadocs hashcode for a map.entry is defined as : int hashCode() Returns the hash code value for this map entry. The hash code of a map entry e is defined to be: (e.getKey()==null ? 0 : e.getKey().hashCode()) ^ (e.getValue()==null…
Abhishek Raj
  • 109
  • 3
  • 10
0
votes
2 answers

Apache Commons HashCodeBuilder: null vs zero for Numeric types

Recently I have encountered the following hashcode "equality" scenario in a Java codebase using Apache Commons Lang 3, and was surprised that I could not find much information on how to handle what seems like it could be a common problem: MyObject…
Matsu Q.
  • 468
  • 1
  • 9
  • 17
0
votes
1 answer

Is there a better way to hash a permutation of a string that consist of any of the 128 legal ASCII characters?

Given that any 2 strings which are a permutation of each other are considered to be the same (eg. (ABACD, BDCAA) and (ABACD, DBACA) should be hashed to the same bucket of a HashMap). The strings only consists of any of the 128 legal ASCII…
whwh
  • 1
0
votes
1 answer

Is it possible to use hashCode as a content unique ID?

I need to compare two large strings. Rather than using an equals method like that, is there a way like a hashCode or something which generates a unique id for String? That is because my String is very large. Also, I need distinct content unique Id.…
Sanka
  • 1,294
  • 1
  • 11
  • 20
0
votes
1 answer

Generating JobId for Android Jobscheduler services

I have multiple JobServices in my app. As per the Android docs, JobId for each JobService has to be unique per uid. In order to avoid collisions, I am using unique String hashcode as my JobId. this can lead to negative JobIds as well. Is this the…
Vivek
  • 1,823
  • 1
  • 19
  • 39
0
votes
1 answer

Can GetHashCode() for the same double result in a different integer?

Is it possible for the GetHashCode() method to return different integer values for the same double value on different computers, operating systems, or architectures? For example, if I have the following code: public unsafe override int…
Vahid
  • 5,144
  • 13
  • 70
  • 146
0
votes
2 answers

Generate Bigger HashCode JAVA

Since there is known fact that Java generates around 4 Billion unique Hashcodes. I am using Hashcode of Some String (Example Fname + Lname + DOB + DATE) which becomes Primary Key of my Database in @PrePersist I set it with Hashcode which helps me in…
Ashish
  • 1,856
  • 18
  • 30
0
votes
0 answers

Inverse of MurmurHash3

I am looking for an inverse function of MurmurHash3_x64_128, as implemented in this Java version. Note that the difference is in initializing h1 and h2 by xoring the seed with some magic numbers. Also, in fact I am interested only in bits 33 - 64…
Radim Vansa
  • 5,686
  • 2
  • 25
  • 40
0
votes
5 answers

How to ensure hashcode() does not resolve to same value in Java?

I have a hashcode implementation for a class and the hashcode implementation is consistent with what eclipse generates and also the most commonly accepted practice as discussed here Here is my hashcode implementation(All the Ids used in this method…
Nohsib
  • 3,614
  • 14
  • 51
  • 63
0
votes
1 answer

Implementing Good hashCode function in java?

I know now a days inbuilt utilities available like HashCodeBuilder from Apache commons lang but i was trying to understand how to implement it myself and came across the example of hascode function for Employee class at…
M Sach
  • 33,416
  • 76
  • 221
  • 314
0
votes
2 answers

How to generate a document ID or Report ID of 8 characters in .net

Can someone point me to the preferred method for generating a report or document ID? I have been looking at maybe using a guid that would be reduced down to a shorter length. We have an application that creates an ID for reports that is about 8…
SDanks
  • 609
  • 1
  • 7
  • 18
0
votes
1 answer

Reliably associate local metadata to a remote file?

WinForms / C# My application allows the user to specify 1) additional information for 2) a given file, both of which are uploaded to the server. There are two isolated uploads: first the file, and (maybe much) later the metadata. Please assume the…
lance
  • 16,092
  • 19
  • 77
  • 136
-1
votes
1 answer

Two Lists are Equal under equals() function but have different hashcodes?

I have two ArrayLists that are equal under the equals() method, but they have different hashcodes. What is going on here? According to the Java List API: "list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1…
Dave
  • 1
-2
votes
2 answers

Java how to make the hash unique

I'm trying to create an abstract class Coin, having instance variables name (a String), symbol (of type java.awt.Image), and hash (a String.) The problem is that I need to make the attribute hash not the same as the one being returned by the default…
sny
  • 3
  • 7
1 2
3