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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:10:02+00:00 2026-05-12T15:10:02+00:00

I am looking for an efficient data structure, that’ll allow me to cue events

  • 0

I am looking for an efficient data structure, that’ll allow me to cue events … that is, i will be having an app, where at any time in execution, it is possible, that an event will be raised for a future point in execution … something like:

  • t=20: in 420 seconds, A occurs
  • t=25: in 13 seconds, B occurs
  • t=27: in 735 seconds, C occurs
  • …

so i’d like to have a data structure, where i can put in any event in any time in the future and where i can get and (by doing so) remove all due events … also, a plus would be, if i were able to remove an event from the datastructure (because it was canceled) … not too important though, since i can simply flag it as cancelled …

my first thought was, maybe to do some sort of tree, but i guess the removing-due-events part requires a lot of rebalancing …

i am considering simply having an int hash, mapping timestamps to either null or stacks of events that are to occur at that point in time … i think in scenarios, with a lot of events (possibly multiple every second – which is what i intend to work with), this actually isn’t such a bad idea after all …

so i am eager to hear your input … 🙂


edit:

  • to be more specific: i think n here is at about 100K-1M, and i guess i might be having about 1-100 events/second …
  • the t is of no special importance … it is only to illustrate that a future event can be “enqueued” at any time …

thanks

back2dos

  • 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-12T15:10:02+00:00Added an answer on May 12, 2026 at 3:10 pm

    If your events have a well defined upper limit (e.g. no events later than 2 days in the future), you can simply have an array indexed by # of seconds from “beginning of time”.
    The value of the array is a list of events at that offset.

    Listing or Removal is very efficient – simply find the offset for the time where you wish to list or cut off and get or re-initialize the arrays pointed to by indices after that offset.

    If your events can stretch out indefinitely into the future, then your own idea of using a hashmap from offsets to list of events is the best one, with a twist – have a sorted list (however you wish to implement it) of known offsets, that way you will have very efficient lookups (e.g. you won’t have to loop over every key ion the map).

    You don’t need to delete anything from the list of known offsets so no issues with re-balancing – you merely delete from the arrays that hashmap points to.

    Also, it seems unclear from your question whether there’s any need to know “t” – the time when the event was raised. If you need to know it, store it as part of the event. but the reference to when the event should happen should all be absolute in relation to some starting point (if it’s a hashmap with unbounded range, you can use epoch seconds, and if events have bounds like in the first array solution I listed, you should instead use “# of seconds since beginning of range” – e.g. from start of day yesterday.

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

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's possible to do this by setting the accesstype of… May 12, 2026 at 9:21 pm
  • Editorial Team
    Editorial Team added an answer You actually need to parse the html and all css… May 12, 2026 at 9:21 pm
  • Editorial Team
    Editorial Team added an answer /Applications/Firefox.app is not an X app it uses Apple's own… May 12, 2026 at 9:21 pm

Related Questions

How do you optimize the heap size usage of an application that has a
I'm am looking for specific suggestions or references to an algorithm and/or data structures
I am trying to come up with the best data structure for use in
In one of my current side projects, I am scanning through some text looking
I am a fairly new MySQL developer and am starting on a project that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.