Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_ArraySearch


  • Please log in to reply
19 replies to this topic

Poll: _ArraySearch (30 member(s) have cast votes)

Does this functionality seem useful?

  1. Yes (25 votes [83.33%])

    Percentage of vote: 83.33%

  2. No (2 votes [6.67%])

    Percentage of vote: 6.67%

  3. Maybe (3 votes [10.00%])

    Percentage of vote: 10.00%

Vote Guests cannot vote

#1 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 31 October 2006 - 03:17 AM

A while ago I coded _ArraySearch. I often find it quite useful. Nonetheless there is one limitation that always bugged me. It didn't support multidimensional arrays. I have some code that adds support for multidimensional arrays. However it is still very much in development. The code I have now is attached below. (along with some examples.)

I am wondering if people would be interested in this kind of functionality.

Attached Files


Edited by P5ych0Gigabyte, 18 January 2010 - 10:22 PM.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.







#2 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 31 October 2006 - 10:20 PM

Updated. More examples are now included . So far no bugs have been found.
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

#3 stampy

stampy

    Polymath

  • Active Members
  • PipPipPipPip
  • 242 posts

Posted 31 October 2006 - 10:37 PM

personally any multidimensional array support is useful. I use mulitdim arrays often and have to build most routines myself.

#4 fisofo

fisofo

    If you can read this, then I suck at being a ninja

  • Active Members
  • PipPipPipPipPipPip
  • 382 posts

Posted 01 November 2006 - 12:16 AM

Ditto on usefulness... I was about to right this one myself, now i guess i don't need to. Thanks :whistle:

#5 fisofo

fisofo

    If you can read this, then I suck at being a ninja

  • Active Members
  • PipPipPipPipPipPip
  • 382 posts

Posted 01 November 2006 - 12:23 AM

Couple thoughts:
1. Right now it returns as soon as something is found, perhaps it should continue checking? Basically, what should it do if there are multiple entries of the same thing?
2. It would be pretty sweet for it to return both indeces when searching as well, otherwise the search has to be performed twice.

These *may* be out of scope, thought i'd ask though and see what you thought.

#6 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 01 November 2006 - 01:04 AM

Couple thoughts:
1. Right now it returns as soon as something is found, perhaps it should continue checking? Basically, what should it do if there are multiple entries of the same thing?
2. It would be pretty sweet for it to return both indeces when searching as well, otherwise the search has to be performed twice.

These *may* be out of scope, thought i'd ask though and see what you thought.


@stampy & @fisofo
Thanks for the replies

@fisofo
Sounds like an interesting idea.Maybe I will implement it after i finish debugging the multidimensional array support.

Edited by SolidSnake, 01 November 2006 - 01:05 AM.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

#7 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,315 posts

Posted 01 November 2006 - 01:23 AM

I say maybe useful in certain circumstances. I can see the ability for it to be used, but fail to see mass use. I'm sure most AutoIt users will find a use for it at least once in their scripts, but not very often.

#8 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 01 November 2006 - 01:31 AM

I say maybe useful in certain circumstances. I can see the ability for it to be used, but fail to see mass use. I'm sure most AutoIt users will find a use for it at least once in their scripts, but not very often.


Thanks for the reply. I usually use single dim arrays but a script i have been working on requires me to work with mulitdim arrrays hence my modification of _ArraySearch. :whistle:

Edited by SolidSnake, 01 November 2006 - 01:32 AM.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

#9 Bounda

Bounda

    Adventurer

  • Active Members
  • PipPip
  • 104 posts

Posted 01 November 2006 - 02:43 AM

i absolutely NEEDED this dude, thx a ton!

#10 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 01 November 2006 - 02:59 AM

i absolutely NEEDED this dude, thx a ton!


no problem. :whistle: thanks for the feedback.
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

#11 VeeDub

VeeDub

    Polymath

  • Active Members
  • PipPipPipPip
  • 202 posts

Posted 13 December 2006 - 12:22 PM

@SolidSnake

I was planning to write some array searching code for a task that I am working on at present and came across your post by luck while browsing through the Example Scripts, hopefully I'll be able to use your code instead, will certainly have a close look.

Either way I think array functions like this are alway going to be useful, computers are good at working with data so that means there always going to be people writing code to sort/search data. May not be every user, but the need will always be there.

VW

#12 randallc

randallc

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,902 posts

Posted 13 December 2006 - 02:48 PM

Hi,
I am confused; the examples are only using 2D arrays . Does it really work for any number of dimensions, or only 1 or 2D?
best, randall

#13 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 14 December 2006 - 03:16 AM

Hi,
I am confused; the examples are only using 2D arrays . Does it really work for any number of dimensions, or only 1 or 2D?
best, randall

Should work with any array. :P

Dim $Array[3][2][2] $Array[0][1][1] = 1 $Array[1][1][1] = 2 $Array[2][1][1] = 3 $Result = _ArraySearchAnyDim ($Array, "2", 0, 0, 0, "[x][1][1]") ;_ArraySearchAnyDim should return 1 ConsoleWrite($Result & "|" & @error & @LF)

Edited by SolidSnake, 14 December 2006 - 03:17 AM.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

#14 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 14 December 2006 - 03:19 AM

@SolidSnake

I was planning to write some array searching code for a task that I am working on at present and came across your post by luck while browsing through the Example Scripts, hopefully I'll be able to use your code instead, will certainly have a close look.

Either way I think array functions like this are alway going to be useful, computers are good at working with data so that means there always going to be people writing code to sort/search data. May not be every user, but the need will always be there.

VW


Thanks for the feedback. :P

Edited by SolidSnake, 14 December 2006 - 03:19 AM.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

#15 Duhhh

Duhhh

    Seeker

  • Active Members
  • 7 posts

Posted 23 February 2007 - 08:49 PM

I just started working on a script that needs a multi-dimensional array search. I'm glad I found yours before I started writing one. I'll be testing it to death, and will let you know if I find anything.

Thanks! :whistle:

#16 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 24 February 2007 - 12:44 PM

I just started working on a script that needs a multi-dimensional array search. I'm glad I found yours before I started writing one. I'll be testing it to death, and will let you know if I find anything.

Thanks! :whistle:

NP. :) Glad you have a use for it. If you are looking for even more features then check out _ArraySearchPlus()

This function combines the features of two different versions of _ArraySearch().
TheGuy0000's _ArraySearch()
SolidSnake's _ArraySearchAnyDim()


Edited by SolidSnake, 24 February 2007 - 12:45 PM.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

#17 Duhhh

Duhhh

    Seeker

  • Active Members
  • 7 posts

Posted 26 February 2007 - 09:26 PM

NP. :whistle: Glad you have a use for it. If you are looking for even more features then check out _ArraySearchPlus()

I saw that - those extra search features haven't hit any of my needs yet, but I was thinking....

What if I added a binary search to all of that (ArraySearch++? :)) So far, I've been able to get enough performance out of my script by not doing redims and other tweaks, but I am doing a bunch of searching in multi-dimensional arrays, so it would probably pay to sort it and then binsearch it. Has anyone else started on this, or should I go for it?

#18 FuryCell

FuryCell

    A cornered fox is more dangerous than a jackal!

  • Active Members
  • PipPipPipPipPipPip
  • 2,437 posts

Posted 26 February 2007 - 11:15 PM

I saw that - those extra search features haven't hit any of my needs yet, but I was thinking....

What if I added a binary search to all of that (ArraySearch++? :)) So far, I've been able to get enough performance out of my script by not doing redims and other tweaks, but I am doing a bunch of searching in multi-dimensional arrays, so it would probably pay to sort it and then binsearch it. Has anyone else started on this, or should I go for it?


I think it would be awesome if you extended the function. I'm sure many would find it useful to have a more robust binary search. I think it would be best if you called it ArrayBinarySearchPlus(). Good luck. :whistle:

Edited by SolidSnake, 26 February 2007 - 11:17 PM.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

#19 crzftx

crzftx

    Prodigy

  • Active Members
  • PipPipPip
  • 195 posts

Posted 30 December 2007 - 11:20 PM

And the function is done. Took a bit of time.

AutoIt         
#cs up to 4 dimensions $avArray is the input array $sFind is a string of what to find $sDimension is a string representing where to look     "[-1][3]" will search all the entire first dimension and only the third subset of the second dimension     "[3,5][-1][3]" will search the 3rd through 5th of d1, all of d2, and the 3rd of d3 $bAll, if true, returns all values in a two-dimensional array with array[0][0] being the number of values     [1][0] will be first dimension's index, [1][2] will be third dimension's index     [2][0] will be second answer's first dimension's index $bAll, if false, will return a single-dimensional array with     [0] being d1's index     [3] being d4's index $iCaseSensative - see StringCompare Help #ce Func _ArraySearchMultiDim($avArray, $sFind, $sDimension, $bAll = True, $iCaseSensative = 0)     Local $w, $x, $y, $z     Local $dimensions = UBound($avArray,0), $lastBreak = 1, $currentDim = 0     Local $start[$dimensions], $end[$dimensions], $i[$dimensions]     If $bAll Then         Local $final[1][$dimensions]         $final[0][0] = 0     Else         Local $final[$dimensions]     EndIf     For $z = 3 To StringLen($sDimension)         $char = StringMid($sDimension,$z,1)         If $char = "," Then             $start[$currentDim] = StringMid($sDimension,$lastBreak+1,$z-$lastBreak-1)             For $y = $z+1 To StringLen($sDimension)                 If StringMid($sDimension,$y,1) = "]" Then                     $end[$currentDim] = StringMid($sDimension,$z+1,$y-$z-1)                     $lastBreak = $y+1                     $currentDim += 1                     $z = $y+2                     ExitLoop                 EndIf             Next         ElseIf $char = "]" Then             $between = StringMid($sDimension,$lastBreak+1,$z-$lastBreak-1)             If $between = "-1" Then                 $start[$currentDim] = 0                 $end[$currentDim] = UBound($avArray,1)             Else                 $start[$currentDim] = Number($between)                 $end[$currentDim] = Number($between)             EndIf             $lastBreak = $z+1             $currentDim += 1             $z += 2         EndIf     Next     For $z = $start[0] To $end[0]         If $dimensions = 1 Then             If StringCompare($avArray[$z],$sFind,$iCaseSensative) = "0" Then                 If $bAll Then                     ReDim $final[UBound($final)+1][$dimensions]                     $final[0][0] += 1                     $final[$final[0][0]][0] = $z                 Else                     $final[0] = $z                     Return $final                 EndIf             EndIf         Else             For $y = $start[1] To $end[1]                 If $dimensions = 2 Then                     If StringCompare($avArray[$z][$y],$sFind,$iCaseSensative) = "0" Then                         If $bAll Then                             ReDim $final[UBound($final)+1][$dimensions]                             $final[0][0] += 1                             $final[$final[0][0]][0] = $z                             $final[$final[0][0]][1] = $y                         Else                             $final[0] = $z                             $final[1] = $y                             Return $final                         EndIf                     EndIf                 Else                     For $x = $start[2] To $end[2]                         If $dimensions = 3 Then                             If StringCompare($avArray[$z][$y][$x],$sFind,$iCaseSensative) = "0" Then                                 If $bAll Then                                     ReDim $final[UBound($final)+1][$dimensions]                                     $final[0][0] += 1                                     $final[$final[0][0]][0] = $z                                     $final[$final[0][0]][1] = $y                                     $final[$final[0][0]][2] = $x                                 Else                                     $final[0] = $z                                     $final[1] = $y                                     $final[2] = $x                                     Return $final                                 EndIf                             EndIf                         Else                             For $w = $start[3] To $end[3]                                 If StringCompare($avArray[$z][$y],$sFind,$iCaseSensative) = "0" Then                                     If $bAll Then                                         ReDim $final[UBound($final)+1][$dimensions]                                         $final[0][0] += 1                                         $final[$final[0][0]][0] = $z                                         $final[$final[0][0]][1] = $y                                         $final[$final[0][0]][2] = $x                                         $final[$final[0][0]][3] = $w                                     Else                                         $final[0] = $z                                         $final[1] = $y                                         $final[2] = $x                                         $final[3] = $w                                         Return $final                                     EndIf                                 EndIf                             Next                         EndIf                     Next                 EndIf             Next         EndIf     Next     Return $final EndFuncƒo݊÷ ؋i®†Únœ¢é]m楊Ûeyö¬µêÛºÖ­•æ¬¶+p¢¹,-±Êâ¦Ö®¶ˆ­sdvÆö&Âb33c·FW7D'&•³%Õ³5Õ³EÐ ¢b33c·FW7D'&•³Õ³Õ³ÒÒ¢b33c·FW7D'&•³Õ³Õ³ÒÒP¢b33c·FW7D'&•³Õ³Õ³%ÒÒ@“²fÇC²Ð¢b33c·FW7D'&•³Õ³Õ³5ÒÒ€“²fÇC²Ð¢b33c·FW7D'&•³Õ³Õ³ÒҐ¢b33c·FW7D'&•³Õ³Õ³ÒÒ`¢b33c·FW7D'&•³Õ³Õ³%ÒҐ“²fÇC²Ò–W0¢b33c·FW7D'&•³Õ³Õ³5ÒÒ “²fÇC²Ð¢b33c·FW7D'&•³Õ³%Õ³ÒÒ¢b33c·FW7D'&•³Õ³%Õ³ÒÒ ¢b33c·FW7D'&•³Õ³%Õ³%ÒÒ@“²fÇC²Ð¢b33c·FW7D'&•³Õ³%Õ³5ÒҐ“²fÇC²Ò–W0¢b33c·FW7D'&•³Õ³Õ³ÒÒ¢b33c·FW7D'&•³Õ³Õ³ÒÒ0¢b33c·FW7D'&•³Õ³Õ³%ÒÒ¢b33c·FW7D'&•³Õ³Õ³5ÒÒP¢b33c·FW7D'&•³Õ³Õ³ÒÒp¢b33c·FW7D'&•³Õ³Õ³ÒÒ¢b33c·FW7D'&•³Õ³Õ³%ÒÒ@¢b33c·FW7D'&•³Õ³Õ³5ÒÒ€¢b33c·FW7D'&•³Õ³%Õ³ÒҐ¢b33c·FW7D'&•³Õ³%Õ³ÒÒ3`¢b33c·FW7D'&•³Õ³%Õ³%ÒÒ@¢b33c·FW7D'&•³Õ³%Õ³5ÒÒ  ¢b33c·FW7Df–æÂÒô'&•6V&6„×VÇF”F–Ò‚b33c·FW7D'&’ÃÂgV÷Cµ³Õ²ÓÕ³"Ã5ÒgV÷C² ¤f÷"b33c·¢ÒFòb33c·FW7Df–æųճР”f÷"b33c·’ÒFò  ”6öç6öÆUw&—FR‚gV÷C²b33c·FW7Df–æŲgV÷C²fײb33c·¢fײgV÷CµÕ²gV÷C²fײb33c·’fײgV÷CµÒÒgV÷C²fײb33c·FW7Df–æŲb33c·¥Õ²b33c·•ÒfײgV÷C²âgV÷C²fײ5$Äb ”æW‡@¤æW‡@ƒo݊÷ ÙK"ž®¶ˆ­sbb33c·FW7Df–æÂÒô'&•6V&6„×VÇF”F–Ò‚b33c·FW7D'&’ÃÂgV÷Cµ³Õ²ÓÕ³"Ã5ÒgV÷C²ÂfÇ6R ¤f÷"b33c·’ÒFò  ”6öç6öÆUw&—FR‚gV÷C²b33c·FW7Df–æŲgV÷C²fײb33c·’fײgV÷CµÒÒgV÷C²fײb33c·FW7Df–æŲb33c·•ÒfײgV÷C²âgV÷C²fײ5$Äb¤æW‡@

also works.
It does not have any sort of error handling, and I didn't check for speed.
If I post a code or snippet, please tell me what I did wrong and/or what I can do better. Tell me my code/idea sucks, if it does. If I ask for help, refrain from only telling me to search the help file and/or the forums. I will search before asking, I just may not have searched with good keywords. If I say that I will look into something or fix something later, understand that I am most likely lying.

#20 Aktonius

Aktonius

    Prodigy

  • Active Members
  • PipPipPip
  • 198 posts

Posted 17 February 2012 - 04:47 PM

thanks FuryCell




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users