Announcement

Collapse
No announcement yet.

Using the binary search function on structured data.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using the binary search function on structured data.

    Does the binary search function only work on "simple" arrays without members?
    miva_array_binarysearch( key, array var, callback, data var )
    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton

    #2
    Don't know, you should go ask that Ray guy who put together mivascript.com :)
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      I'll do that. Do you know how I can get in touch?

      I wrote this to create a simple array that can be searched. It returns a new array by reference to structure member values so it uses less memory and in theory should be faster than making a copy of the data. Maybe someone else has a better idea.

      Code:
      <MvFUNCTION NAME = "SimpleArrayfromStructure" PARAMETERS = "structure var, member, simple var">
          <MvCOMMENT>
              Extract a member from a structured array and return a simple array by reference
              Returns the number if items in the arrays
          </MvCOMMENT>
          <MvFOREACH ITERATOR = "l.item" ARRAY = "l.structure" INDEX = "l.pos">
              <MvREFERENCE NAME = "{ 'l.simple[' $ l.pos $ ']' }" VARIABLE = "{ 'l.item:' $ l.member  }">
          </MvFOREACH>
          <MvFUNCTIONRETURN VALUE = "{ l.pos - 1 }">
      </MvFUNCTION>
      Ray Yates
      "If I have seen further, it is by standing on the shoulders of giants."
      --- Sir Isaac Newton

      Comment

      Working...
      X