Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
How do I create a HashSet of unique values without comparison in Java

I have a complex Java Bean with ~20 attributes. In my business logic, I am generating around 10^5 unique instances of this Bean.

The bean has a complex and performance costly equals method.

My API signature is old and I can return the data only in a HashSet data structure.

I require to generate this HashSet from the unique instances without invoking the equals method of the bean to have the flow optimized.

Is it possible?

It is guaranteed, the data to be inserted in HashSet are unique beforehand.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

IdentityHashMap uses == instead of equals() to compare keys when two of them have the same hash code.

You can create a set from it:

Set<E> set = Collections.newSetFromMap(new IdentityHashMap<>());
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda