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

232
Vistas
Using a HashMap for quickly looking up relationships between two entities

Tools used

Assume the language is JavaScript here, and the implementation of the HashMap is the Map class.

Data structure

Say I have a bunch of "People" objects that look similar to these two (which we will focus on), objects "John" and "Sally".

{
    id: "someUUID-John",
    name: "John"
}
{
    id: "someUUID-Sally",
    name: "Sally"
}

I also have n number of objects representing relationships between the above objects like so:

{
    id: "someRelationshipId",
    from: "someUUID-John",
    to: "someUUID-Sally",
    type: "phone_call"
}

The above example defines a relationship from John to Sally. Assume that there are multiple relationships going this same direction, and multiple going the other way (i.e. from Sally to John). There are also multiple relationships between other "People" objects and between both John and Sally to those other People.

Problem statement

The id of the above relationship is what this question is about.

I wish to use a HashMap to easily look up relationships. At the time I wish to look this up, it's safe to assume one of the two following scenarios:

  • I have a reference to John or Sally, but not both
  • I have a reference to both John and Sally

My question is, A) Is it possible to construct or use a hashing algorithm to generate a key that can be used to look up the relationship given a reference or both of the related objects and B) If so, what algorithm should I use or implement?

about 4 years ago · Juan Pablo Isaza
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