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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:09:12+00:00 2026-06-15T09:09:12+00:00

Basically I have been using a Dictionary object in my program that basically took

  • 0

Basically I have been using a Dictionary object in my program that basically took ints as its keys and stored RTMFP peer IDs in the appropriate locations. Each int was unique and represented one user.

Now I’m needing to expand on this where users are identified by a combination of the int and a Boolean value, kind of like this:

private var m_iUID:int;
private var m_blnIsCurrent:Boolean;

Only the combination between those two really uniquely identifies the user. That being said I was just about to use a new class made out of this for the Dictionary keys; but then it occurred to me that instead of doing it this way, I could just add the peer ID to the class definition and turn the Dictionary object into an ArrayCollection:

private var m_iUID:int;
private var m_blnIsCurrent:Boolean;
public var m_strNearID:String;

So now I’m wondering which is really better in this scenario. And that question has led to a bigger question: where do you really draw the line between these two collection types in general? They’re suddenly starting to not seem all that different after all, except where you’re trying to avoid messing with class definitions. I guess I’m really asking for advice about both the specific scenario and the general question. Thanks!

  • 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-15T09:09:13+00:00Added an answer on June 15, 2026 at 9:09 am

    ArrayCollection is just a wrapper for an Array, and is only available in Flex.

    In AS3 you really have 3 fundamental hash table types: Array, Object, and Dictionary. You choose which one to use based on the type of key you want to use: an integer, a string, or an object reference. Arrays will convert any key to an int, Object will convert any key to a string. Dictionary works like Object for string keys (and will convert primitives to a string) but what it is really good at is using object references as keys.

    It you want to use a single int as the unique key, use an array. If you want to use a single string as the unique key, use an object. If you want to use object references as the unique key, use a Dictionary.

    In your case you should probably use an Object, and a custom toString() method on your “key” class. This is because you want to use a composite of primitive values (NOT an object reference) as your unique key. There is no way to do this natively, so you’ll have to mash the values together as a single string. Objects are the best (fastest) hash table for string keys, so that is the collection you should use.

    Example:

    class User {
        private var m_iUID:int;
        private var m_blnIsCurrent:Boolean;
        public var m_strNearID:String;
        public function User(UID:int, IsCurrent:Boolean) {
            m_iUID = UID;
            m_blnIsCurrent = IsCurrent;
        }
    
        // Custom toString to mash together primitives
        public function toString() {
            return m_iUID.toString() + "-" + (m_blnIsCurrent ? "1" : "0");
        }
    }
    
    // Later:
    var allUsers:Object = {}
    var user1:User = new User(231049, true);
    var user2:User = new User(0x2309, false);
    
    // Implicitly calls toString():
    allUsers[user1] = "User 1";
    allUsers[user2] = "User 2";
    
    // All of the following will successfully retrieve the value for user1 ("User 1"):
    // ONLY the first would work if allUsers was a Dictionary
    trace(allUsers[user1]);
    trace(allUsers[user1.toString()]); 
    trace(allUsers["231049-1"]); 
    trace(allUsers[new User(231049, true)]); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I am using Wireshark looking at captures that have been created previously. How
I have been using LINQ with compiled queries, basically passing into the compiled query
So i have been creating this framework thing that basically puts together source code
I basically have a program that filters records from one excel file to another
I have been using UIViewController s and initWithNibName with much success, basically using them
I have been using repeaters to bind a nested collection . Basically what I
Can anyone help, i have been using log4net with success i basically had a
I have been successfully using quartz in my application. Basically I have quartz bundled
I have been using the embedded server that visual studio has to test my
I have a website that is using SMF forum (simplemachines.org). I have been 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.