SafeList) have a great feature for fast lookups:
BinarySearch. However, the list needs to be sorted in order to use it. You could call
Sort() first, but that would give back all the performance you got with
BinarySearch. It’s better to just keep the list sorted all the time. Unfortunately, there is no function on
SafeList to efficiently insert an item into a list that’s already sorted. Today’s article presents an extension function that adds this functionality on to
IList<T> and even the non-generic
IList so your list will always be sorted for quick lookups with
BinarySearch. Read on for the code, unit tests, and a performance test showing the advantages you stand to gain.
Posts Tagged sorting
Strings and integers sort differently. Unfortunately, this became a problem for me during some recent experiments with Starling. It could be a problem for you too in a variety of situations. Today we’ll look at a workaround I’ve developed to solve this problem, which isn’t nearly as straightforward as you might think.
Stage3D makes a lot of common tasks more complicated. One such task is using a texture/image that has alpha on it. With classic 2D Flash, this is done automatically for us. With
Stage3D, we must resort to some obscure tricks. Today I’ll show you those tricks so you can use alpha textures in your
Stage3D-accelerated Flash app.
AS3 gives you arrays and a way to sort them, but no easy way to keep them sorted as you add elements to them. Today’s article discusses an easy way to do just that: build a sorted array and keep it sorted. As a bonus, the array provides very fast searching for the elements it contains.
The site has had many articles about improving the performance of your app, but never discussed the basic methodology on which all optimizations should be based. Today’s article will go over a scientific approach to optimizing that makes use of a tool known as a profiler and demonstrate using an AS3 application just why it’s so important to usage such a tool.
Linked lists can be much faster than AS3’s
Vector classes if you use them under the right circumstances. It’s been over a year and a half since I last visited the topic, but today it’s time to update my
LinkedList class. Read on for the freshly-optimized code and all-new performance testing and analysis!
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.