In a previous post, I explored ways to accomplish Math.min and max for integers with some bit twiddling (http://guihaire.com/code/?p=549), Today, we are going to explore ways to find the min or the max of 2 Numbers without using the infamous Math class. Lets start with the min. So the basic: min = Math.min(i,j); One way […]

~ read more ~## Monthly archives for August, 2013

# Math.min Math.max integer tricks

Lets explore options today to fast get the min or the max of 2 integers values. Let’s start with the min, so we want to optimize: min = Math.min(i,j); One easy optimization is to use the ?: ternary operator to avoid the glue function call: min = (i<j)?i:j; we can replace the i<j by (i-j)>>31 […]

~ read more ~# Radix SortOn

In this post here, I presented a fast sorting function based on radix algorithm. Today, lets make the code a bit more useful by rewriting it to sort an array of objects, with a “key” string to access our sorting key. The desired API: static public function RadixSorOn(iarray:Vector.<Object> , sorted:Vector.<Object> , key:String):void As seen when […]

~ read more ~# More On Radix and FlashSort

Let’s see how well our FlashSort and RadixSort functions are performing under specific conditions: * when the keys in the array are uniques : ex:[9 7 8 1 3 2 5 6 4 7 8] * when the array is already sorted ex:[ 1 2 3 4 5 6 7 8 9] * when the […]

~ read more ~# Fastest way to clear Alchemy Bytearray Region?

In this post http://guihaire.com/code/?p=681 about radix sorting, we need to clear a portion of our domain ByteArray, and in 2 of the comments, the question was, what is the fastest way to perform that clear? So we have to clear (2048*4)*3 Bytes before writing into the histogram, To clear the memory region, I don’t want […]

~ read more ~
## Recent Comments