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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:18:01+00:00 2026-05-11T16:18:01+00:00

I have a a simple ordered list that could contain 1 million or more

  • 0

I have a a simple ordered list that could contain 1 million or more items. There are only a few actions that are done with this list:

  • lookup in a value exist
  • find the index for a value
  • find value for index
  • add a value
  • get number of items in the list

Once a value is added to the list, it never changes. I append items to the list, no insert or delete.

I need to manipulate this big list, and store it persistently. Right now I am using a database Int => String to represent the list, but I think there should me a more efficient way to do that.

I could use memcached, but I think 2 functions are missing:

  • persistent storage
  • find the index for a value
  • 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-11T16:18:01+00:00Added an answer on May 11, 2026 at 4:18 pm

    It appears that you also need a String -> Int mapping table.

    In Perl the easiest way to do this is to tie a hash to a DBM File (see man perltie).

    Sample code, untested, could almost certainly be improved:

    use DB_File;
    tie %value2index, 'DB_File', 'value2index';
    tie %index2value, 'DB_File', 'index2value';
    
    sub index_count() {
        return scalar %value2index;
    }
    
    sub value_exists() {
        my $value = shift;
        return exists($value2index{$value});
    }
    
    sub append() {
        my $value = shift;
        if (!value_exits($value)) { # prevent duplicate insertions
            my $index = index_count() + 1;
            $value2index{$value} = $index;
            $index2value{$index} = $value;
        }
    }
    
    sub find_index() {
        my $value = shift;
        return $value2index{$value};
    }
    
    sub find_value() {
        my $index = shift;
        return $index2value{$index};
    }
    

    Don’t use this in a multi-threaded environment, there are non-atomic operations here.

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

Sidebar

Related Questions

I have multiple ordered lists. Unfortunately, the order of the items isn't a simple
Should simple JavaBeans that have only simple getters and setters be unit tested?? What
I have a simple webform that will allow unauthenticated users to input their information,
I have a simple 2-column layout with a footer that clears both the right
I have a simple polygon (convex or concave, but no holes) that I need
Simple question. I have an ordered collection of dates. They are UK dates btw
I have a very simple linq query that gets data from two datatables (orderHeader
I have a list of Person s each which have multiple fields that I
I have simple regex \.*\ for me its says select everything between and ,
Ok, i have simple scenario: have two pages: login and welcome pages. im using

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.