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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:51:23+00:00 2026-06-05T21:51:23+00:00

Hi there Stackoverflowers! I was coding a project when I wondered which is the

  • 0

Hi there Stackoverflowers!

I was coding a project when I wondered which is the fastest data structure that allows me the best performance if I have to access/edit a lot that data?

Let me explain with an example.
I have a class called User and a class Event. A User can have many events. Until now, I have implemented this situation with an ArrayList:

public class User{
    ArrayList<Event> events;
    public void process(){
    }
    ...
}
public class Event{
    event data like event time etc.
}

Since I have a lot of users(millions), every user can have potentially thousands of events, and, moreover, I have to access every event of a user with process() method, I think that using structures like HashMaps etc. would not be helpful(If am wrong please tell me).
However, it is obvious that with this number of elements, good performance is a need.

So, what do you think the fastest data structure to handle the events is?

Thank you very much,

Marco.

  • 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-05T21:51:25+00:00Added an answer on June 5, 2026 at 9:51 pm

    This sounds like a job better suited for a database, especially if you want persistence and/or your data may not fit in the main memory of your computer.

    If, however, you insist on doing this in your own code, you might want to have a look at the LinkedHashMap class. It allows direct access to its elements with constant (i.e. O(1)) complexity, while also combining an internal linked list to allow fast iteration over all elements.

    Of course, whether a HashMap structure is helpful depends on what you want to do. If, for example, you want to search events based on some kind of identifier, then a HashMap is ideal.

    On the other hand, if you only need to access events based on their insertion order, then you cannot do much better than ArrayList, since it supports indexed access to its contents with a constant complexity. If you just need to process them in a queue or stack, Java has several implementations of the Deque interface that might interest you.

    Lastly, if you want to insert your keys randomly and have the underlying structure sort them itself, you might find the TreeMap class useful.

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

Sidebar

Related Questions

There is a website called Gild.com that has different coding puzzles/challenges for users to
My dearest stackoverflowers, I want to access the serialized data contained in files with
Hello Stackoverflowers! I have written a relatively simple application that consists of a login
There are many conflicting statements around. What is the best way to get the
Stackoverflowers, I have a resultset from a SQL query in the form of: Category
There are several shading languages available today like GLSL, HLSL, CG, which one to
Hello stack overflowers, I have a desing that uses the flyweight pattern to share
I have a user model in which I have a method for seeing if
There is this strange situation I'm fighting on. I have 3 pages, les call
There is a div (form) which opens on the click of a button. There

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.