Posts Tagged vector

Sorting Vectors

Tags: , , ,

The Array class has a great function: sortOn(). It does a fast sort based on a property of each element of the array. Unfortunately, there is no equivalent in the Vector class. Below are some attempts to get around that limitation and preserve as much of the speed of sortOn() as possible.

Read the rest of this article »

16 Comments

Adding to Arrays and Vectors

Tags: , ,

Adding on to existing arrays and vectors is one of those really common tasks that sounds dreary. Everyone knows about push() and unshift() for single elements and concat() for lots of elements. But what if you want to add a lot of elements to an existing array or vector without allocating a new array or vector? I have the solution.

Read the rest of this article »

5 Comments

Making Vectors Out Of Mixed-Type Arrays

Tags: , ,

The chief quality of Vectors is that they hold a single type of object. This is why they are sometimes called “typed arrays”. So what would happen if you wanted to convert an array of mixed-type objects into a vector?

Read the rest of this article »

No Comments

Dynamic Access: Part 1 (Indexing Arrays and Vectors)

Tags: , , ,

Many classes in AS3 are dynamic, meaning that you can add and remove their fields at runtime. This is powerful, but extraordinarily slow. This series will cover some common ways you might be inadvertently using dynamic access or using it too much. This will help you make your code faster. In the first installation of the series, I’m going to talk about the simple act of indexing an array or vector.

Read the rest of this article »

1 Comment

Comparing Objects

Tags: , ,

The comparison operators (<, <=, ==, >=, >) are clearly core to any programming language. The AS3 docs tell us a little about AS3’s special handling of strings when compared, but there is more to the story.

Read the rest of this article »

5 Comments

Converting Vectors to Arrays

Tags: , ,

Vectors– typed arrays in AS3– are much quicker than arrays and therefore very useful. There are many times where you end up with arrays though and need to convert them into vectors for the bulk of your using that data. This article is about that process.

Read the rest of this article »

3 Comments

Clearing an Array or Vector

Tags: ,

There are many ways to clear an Array or Vector. I’m tired of seeing the foolish ones. Read this and make sure you’re not doing anything foolish:

Read the rest of this article »

5 Comments

The Type-Safety of Vectors

Tags:

I really want to like Vectors, the new typed array functionality in Flash 10. In fact, I use it as often as I can. But there are some really awkward things about it that make it a pain. Here are some gotchas:

Read the rest of this article »

3 Comments