Jump to content

Relationships between strings


Recommended Posts

Hi all,

just a tricky request:

which are the relationships between strings?

I mean, when it can happen then

$vValue < $avArray[$iMid]
 
given, for example,
 
$value = <z:row c0='Sims2000' Platform='DS'
$avArray[$iMid] = <z:row c0='AlphaZero' Platform='Wii' Price='12.99'/>

?

This is simpy part of _arraybinarysearch() and I can't understand when a given string is lower or higher than another one

_arraybinarysearch() uses a binary method to search trough array and given the result ($vValue < $avArray[$iMid]) it gives a +/- 1 to $mid and cycle again

My tries always return the relationship with "<" but I can't understand which logic is used to set a value lower or higher than another one..

M.

Link to comment
Share on other sites

I'm going to hazard a guess, since the code you posted doesn't use _ArrayBinarySearch. Binary representations of strings are numerical. Perhaps that's the answer?

The Binary part of it's name isn't because it uses binary comparisons,it's because the type of search it does is called that. It takes your search pattern, and looks at the halfway point in the array for it, if it's higher it jumps 50% higher into the array to see if it's there, if it's lower it searches 50% lower in the array. By dividing the remaining portion of the array by 50% every iteration it finds the string faster than searching the whole string one item at a time. This is why the array has to be sorted for it to work correctly, because otherwise you will either not find the pattern or it will take a very long time.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

BrewManNH

Thanks for the explanation. I never used _ArrayBinarySearch, but the name is clearly misleading. Coming from a different background I am often bemused by programming terms: Had the function been called _ArrayDeadReckoningSearch it would have made perfect sense to me. As it stands, it just seems to be a misnomer. Perhaps I've been out of school too long. :graduated:

Edited by czardas
Link to comment
Share on other sites

I didn't understand what it meant when I first ran across it myself, the name didn't go with what it did in my mind until I looked it up. I think that this article might explain it a bit better. It's a little confusing but you get the highlights of how it's supposed to work and why it's named what it is. Other than the fact that it needs a sorted array to work correctly, and the current version of it only works on 1D arrays, I'm surprised it isn't used more for large array searching.

BTW, I have created a 2D version of it that searches a sub-item ("column") of the 2D array, the _Array.au3 link in my signature links to a modified Array.au3 file that includes several modified 2D capable array functions.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thanks I'll take a look. Actually Dead Reckoning is not the term I'm looking for although its similar. The term I am looking for is what drafsten have always done with a compass Well anyway, its always good to learn new stuff. ;)

I get the binary part now, although :graduated:

Edited by czardas
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...