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

  • Home
  • SEARCH
  • 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 8581123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:58:24+00:00 2026-06-11T20:58:24+00:00

I am designing the core of my program and have various entities which I

  • 0

I am designing the core of my program and have various entities which I currently loop through to call update(). I have around ten vectors containing my objects, although this might grow to a much larger amount in future. I have just realized I will need to look these up via an id fairly regularly, so I am forced to loop through all elements to look for the correct id.

I am thinking of creating a hashmap that contains the id along with a pointer to the object itself. Is this the most efficient way to do this? The id’s are semi random although they only increase throughout program, with each element in each of the lists having an unique id (each time one is assigned the id counter goes up). The elements in vectors now get removed and added often. I haven’t worked much with hashmaps, other than a small bit in java, so I am unsure if this will be an efficient route to go. I believe the code will still be readable, but are there any options other than hash_map that would be better suited for this? Thanks

  • 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-11T20:58:26+00:00Added an answer on June 11, 2026 at 8:58 pm

    I am not sure why you have 10 vectors – if the objects can be stored in one sorted vector, you may use binary_search to find the object (remember to sort it after every insert).

    Of course, the hash_map also works, at the cost of space/memory.

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

Sidebar

Related Questions

I'm working on designing the kernel (which I'm going to actually call the core
I'm designing a Core Data app which needs to keep dated records. Imagine a
My background with designing data stores comes from Core Data on iOS, which supports
In my program I have currently a piece of code that looks like this
I have a main JavaScript file, we'll call core.js that other file are dependent
I'm designing an iPad/iPhone app using core data. The main focus of the app
When designing a C API for configuring a library/utility, I have a co-worker who
When designing a form I have the option of putting a close button at
Overview: I'm designing a restaurant management application, and I have an entity called Order
I'm currently in the process of developing a fairly large static library which will

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.