Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 982087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:38:30+00:00 2026-05-16T04:38:30+00:00

I need a data structure to store string-int value pairs in an 1:1 relationship,

  • 0

I need a data structure to store string-int value pairs in an 1:1 relationship, and being able too look up from either way their counterpart.

I wrote a class with a Hashtable and a String array and stored the data 2 times and used the built in functions for lookup.

My question is that is there a nicer way to accomplish this? And by nicer I mean being efficient and not storing the data 2 times, and preferably without writing a ton of code either :P.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:38:30+00:00Added an answer on May 16, 2026 at 4:38 am

    It seems like you may be looking for a bimap.

    The Google Collections (now a part of Guava) contains an BiMap interface with a few implementations.

    From the BiMap documentation:

    A bimap (or "bidirectional map") is a
    map that preserves the uniqueness of
    its values as well as that of its
    keys. This constraint enables bimaps
    to support an "inverse view", which is
    another bimap containing the same
    entries as this bimap but with
    reversed keys and values.

    The BiMap.inverse method appears to return a Map with the values as the keys, and the keys as the values, so that Map can be used to call get on the value and retrieve a key.

    In addition the Map returned by inverse is a view of the underlying data, so it does not have to make extra copies of the original data.

    From the BiMap.inverse method documentation:

    Returns the inverse view of this
    bimap, which maps each of this bimap’s
    values to its associated key. The two
    bimaps are backed by the same data;
    any changes to one will appear in the
    other.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am beginner in C++, I need to know which data structure to store
I need a data structure that acts like a SortedDictionary<int, double> but is sorted
I need to store large and complex data structure in a MySql database (I
I need a data structure that holds unique values (like a set), but also
I need a data structure which can handle the following: date_from (datetime) date_to (datetime)
I need a data structure which will support the following operations in a performant
I need to have data structure, each element in which is accessible by pair
I need to design a data structure that supports the following operations: search element
I need to write a data structure that can return a different Price for
I need to decode a data structure containing date and time. Most of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.