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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:17:45+00:00 2026-06-10T03:17:45+00:00

For my application I need a collection that can do fast iteration and fast

  • 0

For my application I need a collection that can do fast iteration and fast lookups by key.

Example Data

var data = [
   { myId: 4324, val: "foo"},
   { myId: 6280, val: "bar"},
   { myId: 7569, val: "baz"},
   ... x 100,000
];

The key is contained within the objects that I want to store. I hacked together Harray (Hash Array) https://gist.github.com/3451147.

Here’s how you use it

// initialize with the key property name
var coll = new Harray("myId");
// populate with data
data.forEach(function(item){ coll.add(item); });
// key lookup
coll.h[4324] // => { myId: 4324, val: "foo"}
// array functionality
coll[1] // => { myId: 6280, val: "bar"}
coll.map(function(item){ return item.val; }); // => ["foo", "bar", "baz"]
coll.length // => 3
// remove value
coll.remove(coll[0]); // delete => { myId: 4324, val: "foo"}
// by key
coll.removeKey(7569) // delete => { myId: 7569, val: "baz"}
// by index
coll.removeAt(0); // delete => { myId: 6280, val: "bar"}

Removal speed seems to be the only tradeoff I can see. The stored objects are shared between the h Object and the Array so I’m not storing 2 copies of anything.

Question

  1. Should I just stick with using for in to iterate through object properties?
  2. Keep an array of the object’s keys instead of the objects themselves?
  3. other options?

Note: browser compatibility is not a factor. This is exclusively for chrome.

  • 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-10T03:17:47+00:00Added an answer on June 10, 2026 at 3:17 am

    In order to know if a specific collection can be helpful, you must :

    • first verify there is a performance problem. If it’s fast enough, don’t worry. To check this, supposing the whole page is slow, use a profiler like the Chrome profiler to check the problem is in the collection you’re currently using

    • then check the alternate collection you’re building is really faster. To do this a common solution is to benchmark both solutions with a big enough data set using a site like http://jsperf.com/ (or simply by building your own timed tests).

    Only after that should you work on ensuring your solution is API-complete, totally bug free, (using test units) and so on.

    Doing the two checks I mentioned first might prevent useless work as the standard objects in the V8 engine are amazingly fast and smart.

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

Sidebar

Related Questions

In my application I need to store a small collection of temporary data. In
I am developing web application where users have collection of tags. I need to
I'm making an application that will analyze real-time data that has been stored to
I'm looking for a data-structure, or combination of several, that can give me a
I have a Form in my application that displays some data. When I first
I want to create a timesheet application where I need an application that will
In my application, _collection is a List from which I need to remove all
my application, written in Java, need to get notified each time internet connection is
The application need write file's last modification date. void Dater(String DateFile) { File file
In the java web application need to select the file from server and print

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.