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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:28:27+00:00 2026-05-15T13:28:27+00:00

What would be the best way to create an array that can have an

  • 0

What would be the best way to create an array that can have an index and a key at the same time ?

i mean something like this

index     | key           | value
0         | "myItem"      | "Some value"
1         | "anotherItem" | "Some other value"
2         | "blabla"      | "Bla Bla"

I know i can create a normal Array/Vector and then use an Object/Dictionary to map the keys to the index in the current array.

But if the array changes then the Dictionary needs to change all the indexes that would have been affected because an item has been removed for example.
I can go ahead and create a class that tries to synchronize the map with the array etc…
But i dont think it is the best way of doing it at all… 🙂

I wanna use it to have a list… that holds queued items for example.
You should be able to get a particular item by its key :

item = list["myItem"]

But you should also be able to find out the index of an item, they have to be ordened , and it should be possible to loop through it as a normal array.

What would be the best way to do something like this in as3 ?

  • 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-15T13:28:27+00:00Added an answer on May 15, 2026 at 1:28 pm

    You say you don’t want to have a reverse index for the keys, so I don’t see how you could achieve what you are after other than having a function that does a linear search in the array and finds an item given an id.

    This assumes your items have a value but also an id: {value:"someValue, id="myItem"}.

    A linear search is not a bad idea anyway, unless you have lots of items in your queue and retrieve them by id very often (specially in a tight loop).

    Now, if you want to go all the way, you can extend Array functionality by extending the Proxy class to make index / id access transparent (that is, your code would get items with queue[0] or queue['myItem']). You’d still have to synchronize the items internally if you have a reverse index or you could just look them up dinamically (with a linear search).

    Check out this answer for pointers on how to do this: extending AS3's Array access operators to 'wrap' out-of-bound index values

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

Sidebar

Related Questions

I would like to see the best way to create a where statement with
What would be the best way to something like this where a timestamp is
What would be the best way to create a JS chat client with GWT?
What would be the best way to create a circularly linked list in C#.
I have learned that the best way to learn a language is by finding
In my model I have an array of objects called events. I would like
I am having difficulty finding the one best way to do something. I have
postgres 9.2 supports json columns. what would be best way to extend postgres to
I want to make a code snippet database web application. Would the best way
What would be the best way to display a dialog whenever my app receives

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.