Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
12 views

Java Hashcode and equals are equals the object are not equals how come?

I have a custom key. However the test to make them equal is failing. The hash and equals have been overriden Can you please give me some clue? @Getter @Setter public class CustomKey { private int ...
matel's user avatar
  • 475
1 vote
1 answer
50 views

What is the most efficient way to key a xyz pair in a C# dictionary?

I have a bunch of objects with xyz pairs (bytes) that I need to add to a dictionary. It's in the tens of thousands and I'm not sure what the most efficient way would be to go about it. Would ...
user2980746's user avatar
-2 votes
1 answer
69 views

HashMap Key and Values, does i need to define equals and hashCode() all time? [duplicate]

I have a question about HashMap<Key,Values>. Let's imagine this scenario: I have a Person class: Person a=new Person(int id, String fullName, int age) I didn't define the equals and hashCode ...
el moutawakil's user avatar
1 vote
3 answers
152 views

.NET combine hash codes insensitive to order

I'm looking for an implementation of hash code to use alongside IReadOnlySet<T>.SetEquals. .NET's HashCode type appears to be order sensitive, so it is not a good fit. var random = new Random(); ...
Kyle McClellan's user avatar
0 votes
0 answers
82 views

How To Tell My MMO Hash Function Code Is Correct

I want to appreciate any feedback you can provide in advance. My current code is the following, written in Python: def g(H): if H[-1] == '0': H = H[:-2] + '11' return H def MMO_hash(...
Melanie Johnson's user avatar
0 votes
0 answers
38 views

low collision hash function for unordered lists

Suppose I have a list of 64-bit integers $X = (x_1,x_2,\ldots,x_N)$. I want to make a hash signature for $X$ with a very low collision rate, preferably one as low as the SHA functions. The catch is ...
Brendan McKay's user avatar
2 votes
1 answer
116 views

NullPointerException when trying to deserialize special object graph with Java 9 or later

I'm workig (as a part of a team) on an Enterprise Java application that has been in active development for 15+ years now. We are looking to build a REST API that would call some of the EJBs of the '...
Gozke's user avatar
  • 31
-1 votes
1 answer
44 views

How to implement equals method for class contains another class in java

I want to compare StudentDTO class object. StudentDTO s1 = new StudentDTO(); StudentDTO s2 = new StudentDTO(); s1.equals(s2) I have Class StudentDTO contains AddressDTO class object as ...
user2042166's user avatar
-2 votes
1 answer
79 views

Why does changing a property of a reference variable in an object changes that object's memory address?

We have the Person class, with 3 variables, "firstName", "lastName" (both String) and "Address" address. Address class has 2 properties, "cityName" and "...
Art's user avatar
  • 37
-1 votes
1 answer
127 views

Different hashCode() in debug and normal Java execution

public static void main(String[] args) { System.out.println(new boolean[] {}.hashCode()); } In normal run result is always 189568618 In debug result is always 321142942 In debug means "-...
michaldo's user avatar
  • 4,539
0 votes
2 answers
325 views

Is this fixup to FNV-1a hash a good idea or a bad idea?

algorithm fnv-1 is hash := FNV_offset_basis for each byte_of_data to be hashed do hash := hash XOR byte_of_data hash := hash × FNV_prime hash := hash XOR ...
Joshua's user avatar
  • 42.5k
1 vote
1 answer
36 views

Firemonkey equivalent to PHP's password_verify() function

Is there a function in Delphi 11.3 FMX that allows me to verify a password with a hash code generated in PHP using password_hash()? A function which does the same as PHP's password_verify($password, $...
M Eugene's user avatar
0 votes
0 answers
75 views

QR Code Generation Issue: Same Output for Different Inputs in Java

I've implemented a QR code generation logic in Java using the SHA-256 hash of input data, but I'm encountering a problem where I get the same QR code for different inputs. I've shared my code below: ...
Prabhat Kumar's user avatar
-2 votes
1 answer
81 views

Will converting hash to integer using modulus result in an even (uniform) distribution of integers?

Say I have this code to convert a hash string into an int: const crypto = require('crypto'); function uuidToInteger(uuid) { // - Create a hash object using SHA-1 algorithm const hash = crypto....
Alexander Mills's user avatar
-1 votes
2 answers
131 views

Java hashCode method for a class with dates and max delta

In java what can be a good hashCode method for a class with a date, where objects are considered equal if the dates have a predefined maximum difference. Example class: public class Test { private ...
user1116377's user avatar
0 votes
1 answer
79 views

How to write equals method using Apache commons-lang3?

package org.sudoku; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.*; public class SudokuBoard { private final ...
jano's user avatar
  • 23
1 vote
2 answers
53 views

median with hash table in sas 9.4

I want to calculate a median by groups for 100 variables with hash tables. I have find this to calculate the median of invoice on sashelp.cars, but if I want to do the median by Make and Model, for ...
mathilde's user avatar
-1 votes
1 answer
58 views

How to use equals & hashcode from generic parent class in child classes? [closed]

I have many Entity classes in my project, and to avoid overriding the equals and hashCode methods in each one, I want to inherit them from a parent class where these methods are already implemented. ...
PRD's user avatar
  • 29
0 votes
1 answer
89 views

Implementing java's `HashCode` in Presto/Trino

I am trying to find a method in SQL world (specifically Trino/Presto) where I can reproduce the following Input / Output combination. Input - s (type String) Output - o Int where o = hashCode(s) E.g. ...
Heisenberg's user avatar
  • 1,508
0 votes
4 answers
70 views

since java creates a new object when new keyword is used, and every object has unique hashcode, then why here it is giving same hashcode output?

public class Main { public static void main(String[] args) { String str1="shrey"; String str2="shrey"; String str3=new String("shrey"); ...
Shrey Saxena's user avatar
1 vote
0 answers
88 views

Why is int.MinValue.GetHashCode() == int.MaxValue.GetHashCode() is false, but Int64.MinValue.GetHashCode() == Int64.MaxValue.GetHashCode() is true?

Why is int.MinValue.GetHashCode() == int.MaxValue.GetHashCode() is false, but Int64.MinValue.GetHashCode() == Int64.MaxValue.GetHashCode() is true? For both 32-bit integer and 64-bit integer, MinValue ...
Leonid Umanskiy's user avatar
3 votes
1 answer
141 views

How do I find three different strings with hash collisions, without using a brute force approach?

I've seen the following question for a hiring interview: How do you find three different strings that have the same hash code in C#? In other words, given the strings a, b, and c, the following four ...
Arseni Mourzenko's user avatar
1 vote
1 answer
102 views

In Java, during Object#equals() call, do both objects necessarily have same hashCode ? Do we need to ever compare hashCode within equals()?

I have read somewhere, in context of HashMap : hashCode() allows sorting objects by their hash values, and then the Object#equals method only needs to be invoked when objects share the same hash value....
HyperVol's user avatar
  • 146
1 vote
1 answer
318 views

Yet Another Implementation of JPA Entity equals()/hashCode()

The history of the JPA entity equals() and hashCode() methods started a long ago. There is a ton of discussions, just google for the "jpa equals hashcode" and you'll find a brilliant Vlad ...
Andriy Slobodyanyk's user avatar
0 votes
3 answers
139 views

Understanding JVM Behavior: How Does `switch` Handle String Hash Collisions?

During an interview, I was posed an intriguing question about how the Java Virtual Machine (JVM) handles a switch statement involving a String type. Specifically, I was asked whether the JVM employs ...
maplemaple's user avatar
  • 1,475
1 vote
2 answers
85 views

Two different HashMap returning the same hashCode

I have two different sets of HashMap ({u=0, h=3} and {t=3, i=0}), and it is returning the same hashCode (224). I don't understand this, hashCode needs to be different for different objects, and here ...
Anguraj Dinesh's user avatar
1 vote
1 answer
109 views

Many to one hash function

I don't know exactly what to call it and this is the closest thing that I can think of What I'm looking for is a function that takes an array of strings and returns a hash string like the following ...
Jalal Hejazi's user avatar
1 vote
1 answer
215 views

Why are 2 org.apache.hc.core5.http.Header not equal when created with the same content?

Why does import org.apache.hc.core5.http.Header; Assertions.assertEquals(new BasicHeader("name", "value", true), new BasicHeader("name", "value", true)); or ...
Martin WasGehtSieDasAn's user avatar
2 votes
2 answers
381 views

Get hashcode of a HashSet based on the items present in the HashSet

I have a HashSet<T> and I want to get the hashcode of the HashSet<T> based on the items it contains. I am trying to identify a HashSet<T> based on it's values. I know I can use set ...
karthik suryadevara's user avatar
-2 votes
1 answer
108 views

i have a hash code which i gotta write at java [closed]

import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class EmailDecoder { public static void main(String[] args) { String ...
berry.11's user avatar
1 vote
1 answer
52 views

Unique Seed based on values & order on a set of Parameters

I have to generate a unique "Hash" based upon an array of parameters. So far I've been using string builder to generate a unique string for every set of parameters, and then using ...
Birger Evansson's user avatar
0 votes
0 answers
40 views

Updating entities with OneToMany mappings: Spring Data JPA

I have a requirement where I need to update the entities on either side of a ManyToMany mapping. I have a InsurancePolicy entity- @Entity @Table(name = "insurance_policy") @Setter @...
ayush's user avatar
  • 664
1 vote
1 answer
296 views

How to get constant hashcode (Uint32 or Int32) for a string but being outside of a range

According to this article the official "GetHashCode" for a string is made randomly per execution to prevent Hacking. But I need to persist the hashcode so I want it to be always the same per ...
Eric Ouellet's user avatar
  • 11.6k
1 vote
1 answer
1k views

Hashcat Combinator 3 word attack

I am able to do a two word combinator attack using Hashcat but when I try to add a third word list it does not work but no error is generated, only to use --help for assistance. Hashcat version is 6....
drive's user avatar
  • 11
0 votes
1 answer
239 views

Generating three distinct strings with equal hashes using the default hash function in C#

I am trying to generate three distinct strings, A, B, and C, such that their hash values are all equal using the default hash function provided by the programming language. Specifically, I need to ...
Ahmadou Kassoum's user avatar
2 votes
1 answer
505 views

Kotlin get default hashCode implementation for inherited class

Before overriding, each class in Kotlin/JVM has default equals/hashCode implementation. Equals is checking for reference equality with ===, but hashCode is something else (and I don't know what it is)....
waterstopper's user avatar
0 votes
0 answers
101 views

Python hash() function not distributing uniformly?

I am experiencing an odd behavior with python's built-in hash() function. I am writing hashes of strings (which come from various language/text datasets) into 900 different files, according to the ...
joinijo's user avatar
  • 433
2 votes
1 answer
227 views

How is a 32-bit hashCode stored in a 25-bit mark word in Java without data loss?

I've been looking into the internals of Java objects and am puzzled about how hashCode values are managed. As I understand it, the hashCode method in Java returns a 32-bit integer. However, this ...
SadMan's user avatar
  • 41
2 votes
2 answers
124 views

What is the key in the Set's underlying HashMap: hash code or the object itself?

Is this sentence from an OCP book correct? A HashSet stores its elements in a hash table, which means the keys are a hash and the values are an Object. I have created below code snippet: class A { ...
bridgemnc's user avatar
  • 312
0 votes
1 answer
45 views

Debugging an SBCL User-Defined Hash-table Test

I'm having trouble understanding an SBCL 2.3.2 error message involving a user-defined hash-table test. Also, is there a better/faster way to implement this? debugger invoked on a TYPE-ERROR @2226541F ...
davypough's user avatar
  • 1,909
1 vote
0 answers
66 views

How to exclude some fields of subclasses from Apache Commons-> HashCodeBuilder.reflectionHashCode

I am trying to exclude some fields for a subclass during the hashcode generation, and it seems that either I have the option to exclude it entirely or none, but not the specific fields even after ...
user1416932's user avatar
0 votes
1 answer
29 views

Java - When does the hash code of an uninitialized array element get determined?

//1 int\[\]\[\] arr = new int\[2\]\[2\]; System.out.println(arr\[0\]); // \[I@7d6f77cc System.out.println(arr\[1\]); // \[I@5aaa6d82 System.out.println(System.identityHashCode(arr\[0\])); // ...
ChoCoc's user avatar
  • 1
0 votes
1 answer
97 views

Hash Code Builder generate duplicate hash code

I want to get 2 hash code of 2 difference group number as below but they have the same result. I can not understand why this happen. Please help to resolve this issue. new HashCodeBuilder(17, 37)....
HieuBui's user avatar
  • 57
1 vote
2 answers
218 views

Can I cache getClass.hashCode()?

Whatever the reason, I have the following hashCode implemented in my abstract class. @MappedSuperclass abstract Some { @Override public boolean equals(final Object obj) { // ... } ...
Jin Kwon's user avatar
  • 21.6k
1 vote
1 answer
670 views

Equals Verifier fails with error related to hashcode check for JPA entity

Given we have such class: @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Entity public class User { @Id private Long id; private String name; private Integer age; @...
ColdDeath's user avatar
1 vote
1 answer
242 views

.equals() on a PriorityQueue returns unexpected results

I'm sorry if this is a dumb question (especially for someone who has developed in java for over 4 years) or if it has been answered (I've searched stack overflow and despite the simplicity of the ...
Contone's user avatar
  • 45
0 votes
0 answers
39 views

Unique string representation of Expression<Func<T, bool>> and Func<IQueryable<T>, IIncludableQueryable<T, object>>

I'm having troubles implementing a cached repository: I'd need to get a unique identifier for these 2 objects which are a Expression<Func<T, bool>> and Func<IQueryable, ...
greyhame's user avatar
  • 264
1 vote
2 answers
171 views

How to correctly implement equals(), hashCode() if the values are within a range of each other?

The criteria is that equals() method where the objects are considered equal if the value of the double variable is within +/- 10 of the other object's value of the double variable. I'm not sure how to ...
casao01's user avatar
  • 37
0 votes
1 answer
42 views

A special function for uids

I have an unique identifier (uid) x, and given an integer j, I need a function f such that f(x, j) is another uid (in the same "domain" as x) such that f(x, j1) = f(x, j2) if and only if j1 =...
helperFunction's user avatar
-3 votes
2 answers
505 views

equals and hashCode with many fields in Java? [closed]

In Java apps, I prefer to use unique fields in equals and hashCode methods instead of adding only id field or all the fields. However, I am confused about the following points: By considering object ...
Jack's user avatar
  • 1

1
2 3 4 5
41