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

The Archive Base Latest Questions

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

I have an application that deals with data in the following structure: struct Message

  • 0

I have an application that deals with data in the following structure:

struct Message
{
   int    time;
   string name;
   string details;
};

For example, I may have a data set that looks like the following:

9:00:00 Bob  <Info>
9:01:00 John <Info>
9:05:00 Bob  <Info>
9:11:00 Mary <Info>
9:17:00 John <Info>
9:25:00 Mary <Info>
9:30:00 Bob  <Info>

And I will have a list of Message structures that represent each line in the data set.

Some operations I will need to do on this data include:

  • Collect all data in chronological order and dostuff()
  • Collect all data from John (or whoever) in chronological order and dostuff()

So, I need a way to traverse the list such that I can pass every message in chronological order, and also choose a person, and pass through only their messages in chronological order.

My thoughts are to have a struct like this:

struct Node
{
   Message* message;
   Node*    next_time;
   Node*    next_name;
};

In which next_time points to the next Node in chronological order, and next_name points to the next Node that belongs to message->name. And a Root structure points to the first of each type.

struct Root 
{
   Node* first_time;
   Node* first_bob;
   Node* first_john;
   Node* first_mary;

   Node* last_time;
   Node* last_bob;
   Node* last_john;
   Node* last_mary;
};

Here is an image to illustrate the point.

enter image description here

This structure allows me to fairly easily traverse through every message, or through only Bob’s messages, or only John’s, etc.

However, I am worried that maybe this is more complicated than it needs to be. I also have concerns about maintenance (see below). I need the search/select/read operations to be pretty fast, which I think they are. And I need insert operations to be reasonably fast. But right now, for every Message I insert, I must (1) update some next_time pointer and (2) update some next_name pointer.

My question is:
Does a data structure exist that provides this type of functionality already? If not, am I approaching this problem correctly?

Please provide any code samples in C++ or C#, if possible.

Thanks.

Additional: Suppose later I want to add to my Message struct. Let’s say I add a field called City. Now, I may want to do this:

  • Collect all data from a specific City in chronological order and dostuff()

This would require adding a next_city, and then for every insert, I would have to update next_time, next_name, AND next_city.

Further, suppose I want to do this:

  • Collect all data from a specific City AND a specific name in chronological order and dostuff()

I think this makes the problem incredibly more difficult unless I opt to traverse every Message and skip the ones I don’t care about.

  • 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-24T05:20:45+00:00Added an answer on May 24, 2026 at 5:20 am

    A simple linked list of all messages (sorted by time).

    struct Node
    {
       Message* message;
       Node*    next_name;
    };
    

    This will satisfy req 1. You can add() and getAll() in O(1)

    A separate hashmap with User as key and a list of Node* as values.

    Hashmap
    {key = User, value = List(Message*)}
    

    This will satisfy req 2. You can add a new entry to the end of the list of the specific user O(1) and getAllOfUser() can also run in O(1)

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

Sidebar

Related Questions

I have developed an application with Spring MVC that deals with bulk data insert/update.
I have an application that reads a CSV file with piles of data rows.
I have an application that has to deal with getting special characters in its
I have an application that sends messages to an external web service. I build
I have an application that displays an image inside of a Windows Forms PictureBox
I have an application that uses NHibernate as its ORM and sometimes it experiences
I have an application that I would like to embed inside our companies CMS.
I have an application that sends the customer to another site to handle the
I have VB application that requires visual service pack 6 to run , now
I have an application that reads a database and outputs alerts to any dependencies

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.