Posts Tagged key

Int Keys: Object vs. Dictionary vs. Array vs. Vector

Tags: , , , , , , , ,

Given that Object and Dictionary can have int keys and that int keys are faster than String keys, a natural performance test follows: which class is fastest at reading from and writing to those int keys? Is there a difference between the four Vector classes? Today’s article performs just that test and comes up with the answers.

Read the rest of this article »

8 Comments

String Keys vs. Int Keys

Tags: , , , , , ,

Now that we know you can use int keys with Object, it’s time to test whether or not this is any faster than String keys. Today’s article does just that and also tests int and String keys with Dictionary.

Read the rest of this article »

10 Comments

Using Non-String Keys with Object

Tags: , , , ,

Pop quiz: what’s the difference between an Object and a Dictionary? If you said “Dictionary can have non-String keys”, you bought into a common myth. Today’s article shows the cases where the lowly Object class will use non-String keys whether you like it or not. Read on for the details.

Read the rest of this article »

7 Comments

Maps With Int Keys: Array vs. Dictionary

Tags: , , , , , ,

Behind the scenes Array holds its values in two ways: a densely-packed array at the beginning and a sparsely-packed map after that. This means it can be used as a map where the keys are indexes and not take up a huge amount of wasted space. Dictionary can also have int keys. Which is faster? Today we’ll find out!

Read the rest of this article »

7 Comments

Typesafe Dictionary

Tags: , , , ,

One of the advantages of using Dictionary instead of Object when mapping key-value pairs is that you can use whatever type of key you want, not just a String. However, a recent comment points out that the keys are still checked with the loose equality operator (==) and you can therefore get clashes like 4 == "4". For today’s article, I’ve written a TypesafeDictionary class that allows you to overcome this limitation. Read on for the implementation, performance testing, and more.

Read the rest of this article »

4 Comments

Fast AS3 MultiMap

Tags: , , , ,

Sometimes you need to map a key to many values, but AS3 has no built-in data structure for this purpose. Dictionary and Object are suitable one-to-one maps, but there’s been no one-to-many support until now. Read on for my own one-to-many class—MultiMap—as well as performance testing and analysis.

Read the rest of this article »

39 Comments