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.
Posts Tagged key
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.
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!
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.
Sometimes you need to map a key to many values, but AS3 has no built-in data structure for this purpose.
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.