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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:34:32+00:00 2026-05-28T20:34:32+00:00

I’m trying to implement a system where I’ll have key-value structure pairs. They will

  • 0

I’m trying to implement a system where I’ll have key-value structure pairs. They will need to be held in some sort of linear manner (that is, they can be indexed), and once given a position can’t be moved, so insertions can only append (and there can’t really be much sorting.) Just as an example this is what is had in mind:

Data list:
    0: { "somekey", somevalue }
    1: { "someotherkey", someothervalue }
    ...
    n: { "justanotherkey", justanothervalue }

I’ve designed the system like this so that when a key is searched for, it’s index can be cached and then accessed with constant time. Now, since I have no way to predict the order or volume of the data, and I can’t sort it, I need ideas on algorithms or data structures that would be better than just a linear seach, but still keep the constraints I’d like.

Anyone got any ideas? I doubt I can speed it up much, but every little bit helps since this will be the core of my system. Thanks in advance!

==EDIT==

The idea of using two seperate structures (like a hash table and a dynamic array) was actually my first intention. Unfortunately, this won’t work for me because I can’t seperate the key and the value. The key will be used for errors and messages, so even once an index has been cached, the original key will still be needed to be accessed. Basically they have to just be an array structs, such as:

struct Entry {
    /* Key is actually a complex struct itself with string, and params */
    Key key;
    Data* data; 
}
  • 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-28T20:34:33+00:00Added an answer on May 28, 2026 at 8:34 pm

    One option would be to use a combination of a hash table and a dynamic array. The idea is as follows – whenever you insert an element into the data structure, you append it to a dynamic array, then insert the key into a hash table associated with the index into the dynamic array at which the key/value pair resides. That way, to look up by index, you can just look in the dynamic array, and to look up by name, you look up the index in the hash table, then query at that index. This takes expected O(1) time for insertion, deletion, and access, which is much faster than a linear search.

    Hope this helps!

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.