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 8746931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:16:25+00:00 2026-06-13T12:16:25+00:00

I need to implement a search method on a large number of objects. The

  • 0

I need to implement a search method on a large number of objects. The strategy is the following:
There are two classes, say,

A{
String a1,
String a2,
...
}
and
B{
String b1,
String b2,
...
}

and two ArrayLists with objects of each type.
I need to find an A object where A.a1 == B.b1. If none is found, I need to find an A object where A.a2 == B.b2 and so on.. (Here == stands for value-based equality as there may be attributes of other types)

What is the best way of making this as fast as possible? The only thing I could think of so far (besides iterating over arrays) is to create a number of HashMaps with attribute values as keys and Object references as values.

Is there a better way of solving this?

  • 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-06-13T12:16:26+00:00Added an answer on June 13, 2026 at 12:16 pm

    You should choose the HashMap way. The lookup is very efficient because of the hashs. And the memory overhead shouldn’t be dramatic as only references are stored in the different Maps.

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

Sidebar

Related Questions

I need to implement the following: There is a table A which is supposed
I need to implement string.IndexOf functionality without using any c# string search related built
I need to implement a Query Object Pattern in Java for my customizable search
I need to implement a thread pool in Java (java.util.concurrent) whose number of threads
I am planning to implement database search through a website - I know there
I need to implement the following but I'm not shure what the best way
Question Summary: Is there a better method than the one posted below to implement
I need to implement some search functionality within a Rails application. Most of the
This API call returns a potentially large List<String>, which is not sorted. I need
I need to implement the following function. I'm open to using the best class,

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.