Fast numeric lookup?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: Fast numeric lookup?

Threaded View

  1. #1

    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[0] return 0, for everything between SIZES[0] and SIZES[1] 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center