November 6th, 2009, 05:31 AM
Fast numeric lookup?
I am not sure this is even possible, but the issue I have is that I have a method I call over and over and over which tries to map a value to an index.
For numbers between 0 and SIZES return 0, for everything between SIZES and SIZES return 1, and so on.
Right now I just loop though, but the problem is that for the higher values it slows down a bit. Sizes is length of 10 or so, but it gets called constantly. A tree of some kind seems a bit much, and I don't see if that would really be faster. I guess linear search would be slightly faster, but with n of ten might it not be slower?
A switch would be nice, but there's no way to easily round the size to the right values.
EDIT: NM. Of course I think of a simple solution the moment I post.
Last edited by originalfamousjohnsmith; November 6th, 2009 at 05:40 AM.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!