#How to have a list that has two keys?

1 messages · Page 1 of 1 (latest)

elfin sable
#

I am planning to create a string hashmap, and I want to fetch the record using either conn_id or user_id.

unique harbor
#

You can:

  • Store the same record for each key if space isn't an issue.
  • Store the same record's pointer for each key. Have a separate ArrayList of records. Convenient if you want to edit the records.
    I'd hope you can avoid this by converting conn_id to its user_id equivalent, though.
abstract niche
#

Use the adapted variant of the hashmap

#

Unsure how you’d make them hash to the same index though

stark ridge
#

you'll need to be careful to keep them both in sync, but that shouldn't be too hard