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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:20:24+00:00 2026-05-24T08:20:24+00:00

For my game, when an object enters a sensor, I need to add it

  • 0

For my game, when an object enters a sensor, I need to add it to a list, and when the object leaves the sensor it needs to be removed from that list. I also need to quickly be able to find that object.

So essentially:

I need it to do:
quick adding, quick removal and quick find.

What sort of data structure would be best for this given that at any given time, the stucture will have about 10 objects.

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-05-24T08:20:24+00:00Added an answer on May 24, 2026 at 8:20 am

    With 10 objects anything will do (std::vector, deque or set), and nobody can tell which one performs better before profiling.

    If you don’t know what to use, perhaps you’ll find that std::set has a nicer syntax for looking up elements. This is what I would use in this situation, because I wouldn’t like to write std::find(v.begin(), v.end(), sensor) where I could simply write s.find(sensor).

    Don’t use std::list though, as a general advice. You need a compelling reason to use linked lists in C++ (constant time splicing is one, absence of iterator invalidation is another). Other data structures perform better for most operations (except splicing). Here, I don’t see any point in using list rather than eg. set.

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

Sidebar

Related Questions

I'm working on a small roguelike game, and for any object/thing that is not
I have a game object that manages several sprite objects. Each of the sprites
I am trying to make a game object that can be made semitransparent during
I was wandering if it's possible to mock a Game object in order to
I've been trying to implement a simple component-based game object architecture using Objective-C, much
I instantiate the HttpWebRequest object: HttpWebRequest httpWebRequest = WebRequest.Create(http://game.stop.com/webservice/services/gameup) as HttpWebRequest; When I post
I have an object: POP_CULTURE_TYPES = ( ('SG','Song'), ('MV', 'Movie'), ('GM', 'Game'), ('TV', 'TV'),
I'm planning on creating a game that contains a landscape with objects on it.
game.h needs: - packet.h - socket.h socket.h needs: - game.h The problem comes when
private void displayResultsButton_Click(object sender, EventArgs e) { gameResultsListView.Items.Clear(); //foreach (Game game in footballLeagueDatabase.games) //{

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.