#include $test = _Create_Vector() for $x=1 to 15 _Vector_PushBack($test,$x) Next $test1=_Vector_Heap($test) _Vector_Heap_Sort($test1) _Vector_Display_Heap_Sample($test1) ;<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~pretty sweet ;~ $test = _Create_Vector(4,99) ;~ $test[4]=100 ;~ _Display_Vector($test) ;~ _Vector_PushBack($test,111) ;~ _Display_Vector($test) ;~ _Vector_Insert($test,3,999) ;~ _Display_Vector($test) ;~ _Vector_PushFront($test,1234) ;~ _Display_Vector($test) ;~ _Vector_PopBack($test) ;~ _Display_Vector($test) ;~ _Vector_Swap($test,_Vector_Begin($test),_Vector_End($test)) ;~ _Display_Vector($test) ;~ _Vector_Sort($test,True) ;~ _Display_Vector($test) ;~ _Vector_Sort($test,False) ;~ _Vector_Reverse($test) ;~ _Display_Vector($test) ;~ MsgBox('',"min",_Vector_Min($test),1) ;~ MsgBox('',"max",_Vector_Max($test),1) ;~ _Vector_Shuffle($test) ;~ _Display_Vector($test) ;~ $test2=$test ;~ _Vector_Sort($test) ;~ _Display_Vector($test) ;~ _Vector_Reverse($test) ;~ _Display_Vector($test) ;~ MsgBox('',"Is_Permutation",_Vector_Is_Permutation($test,$test2),1) ;~ _Display_Vector($test) ;~ _Vector_For_Each($test,y_plus_y) ;~ _Display_Vector($test) ;~ $test=_Create_Vector_Random_Nums(10,1,100) ;~ _Display_Vector($test1) ;~ MsgBox('',"isHeap",_Vector_Is_Heap($test),1) ;~ for $x=1 to 4 ;~ _Vector_Permutation_Next($test,1,4,1) ;~ _Display_Vector($test) ;~ Next ;~ for $x=1 to 4 ;~ _Vector_Permutation_Prev($test,1,4,1) ;~ _Display_Vector($test) ;~ Next ;~ $test=_Vector_String_To_Vec("abcd") ;~ _Display_Vector($test) ;~ dim $test[4] ;~ $test[0]="abcd" ;~ $test[1]="autoit" ;~ $test[2]="badabing" ;~ $test[3]="this is just a test" ;~ MsgBox('','size',_Vector_Size($test),1) ;~ $test=_Vector_String_To_Vec($test) ;~ _Display_Vector($test) ;~ for $x=_Vector_Begin($test) to _Vector_End($test) ;~ _Vector_Sort($test[$x]) ;~ _Display_Vector($test[$x]) ;~ Next ;~ $test1=_Create_Vector_Random_Nums(5,0,100) ;~ _Display_Vector($test1) ;~ $test2=_Create_Vector_Random_Nums(8,0,100) ;~ _Display_Vector($test2) ;~ $test3=_Create_Vector_Random_Nums(5,0,100) ;~ $test1=_Vector_Merge_Sort($test1,$test2) ;~ _Display_Vector($test1) ;~ $test1=_Vector_Merge($test1,$test2) ;~ _Display_Vector($test1) ;~ $test=_Vector_Merge_Sort_Quick($test1,$test2) ;~ _Display_Vector($test) ;~ MsgBox('','Is_Merge',_Vector_Is_Merge($test,$test1,$test3),1) ;~ $test = _Create_Vector(4,99) ;~ _Vector_PushBack($test,100) ;~ _Vector_PushBack($test,100) ;~ _Vector_PushBack($test,101) ;~ _Vector_PushBack($test,101) ;~ _Vector_PushBack($test,101) ;~ _Vector_PushBack($test,101) ;~ _Vector_PushFront($test,89) ;~ _Vector_PushFront($test,89) ;~ _Vector_PushFront($test,89) ;~ _Display_Vector($test) ;~ _Vector_Unique($test,99) ;~ _Display_Vector($test) ;~ $a=_Vector_Find_All($test,100) ;~ _Display_Vector($a) ;~ $test=_Create_Vector() ;~ _Vector_PushBack($test,"abc") ;~ _Vector_PushBack($test,"abcd") ;~ _Vector_PushBack($test,"bc") ;~ _Vector_PushBack($test,"Sydney") ;~ $a=_Vector_Find_All_UPred($test,_Sample_UPred) ;~ _Display_Vector($a) ;~ $test=_Create_Vector_Random_Letters(100,False,True) ;~ _Display_Vector($test) ;~ $test=_Create_Vector_Random_Strings(10,8,15,True,True,True) ;~ _Display_Vector($test) ;~ $test=_Create_Vector_Random_Nums(10,0,100) ;~ $test=_Vector_Partition_UPred($test,_Sample_UPred2) ;~ MsgBox('','is_partitioned',_Vector_Is_Partitioned_UPred($test,_Sample_UPred2)) ;~ MsgBox('','upperbound',$test[_Vector_UpperBound($test,50)],1) ;~ MsgBox('','lowerbound',$test[_Vector_LowerBound($test,50)],1) ;~ _Display_Vector($test) ;~ _Vector_PushBack($test[0],1) ;~ _Display_Vector($test[0]) ;~ _Display_Vector($test[1]) ;~ $test=_Create_Vector_Random_Letters(5000) ;~ $test=_Create_Vector_Random_Nums(10000,0,1000) ;~ MsgBox('','','here',1) ;~ _Vector_Sort($test) ;~ _Display_Vector($test) ;~ $test=_Create_Vector() ;~ _Display_Vector($test) ;~ $test1=_Create_Vector() ;~ for $x=1 to 100 ;~ _Vector_PushBack($test,$x) ;~ Next ;~ _Vector_Shuffle($test,1,10,20) ;~ _Vector_Rotate($test,1,1,1,3,5) ;~ for $x=5 to 10 ;~ _Vector_PushBack($test1,$x) ;~ Next ;~ _Display_Vector($test) ;~ _Display_Vector($test1) ;~ ConsoleWrite('here') ;~ MsgBox('','find_end',_Vector_Find_End($test,$test1),1) ;~ Local $test ;~ _Vector_Insert($test,8,234,True) ;~ _Display_Vector($test) func _Sample_UPred2($x) if mod($x,2)=0 Then Return True Return False EndFunc func _Sample_UPred($x) $s=StringSplit($x,"a") if $s[0]>1 then Return True Else return False EndIf EndFunc func _Vector_Swap(ByRef $vec,$it1,$it2,$Is_Vector=True) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$it1,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$it2,$Is_Vector) then Return -1 if $it1=$it2 then Return $temp=$vec[$it1] $vec[$it1]=$vec[$it2] $vec[$it2]=$temp EndFunc func _Vector_PopFront(ByRef $vec,$Is_Vector=True) if not IsArray($vec) then Return -1 _Vector_Erase($vec, _Vector_Begin($vec,$Is_Vector)) EndFunc func _Vector_PushFront(ByRef $vec,$data,$Is_Vector=True) if not IsArray($vec) then $vec=_Create_Vector(0,"",$Is_Vector) EndIf _Vector_Insert($vec,_Vector_Begin($vec,$Is_Vector),$data,$Is_Vector) EndFunc func _Vector_Front($vec,$Is_Vector=True) if not IsArray($vec) then Return -1 Return $vec[_Vector_Begin($vec,$Is_Vector)] EndFunc func _Vector_Size($vec,$Is_Vector=True) if not IsArray($vec) then Return -1 return $Is_Vector ? $vec[0] : UBound($vec) EndFunc func _Vector_Insert(ByRef $vec,$it,$data,$Is_Vector=True) if not IsArray($vec) Then $vec=_Create_Vector($it-$Is_Vector,"",$Is_Vector) $tempvec = $vec redim $vec[UBound($vec)+1] if $Is_Vector then $vec[0]+=1 $vec[$it]=$data for $x = $it+1 to UBound($vec)-1 $vec[$x] = $tempvec[$x-1] Next EndFunc func _Vector_Back($vec) if not IsArray($vec) then Return -1 Return $vec[UBound($vec)-1] EndFunc Func _Vector_PopBack(ByRef $vec,$Is_Vector=True) if not IsArray($vec) then Return -1 _Vector_Erase($vec,UBound($vec)-1,$Is_Vector) EndFunc Func _Vector_PushBack(ByRef $vec,$data,$Is_Vector=True) if not IsArray($vec) then $vec=_Create_Vector(0,"",$Is_Vector) EndIf ReDim $vec[UBound($vec)+1] if $Is_Vector then $vec[0]+=1 $vec[UBound($vec)-1] = $data EndFunc func _Vector_Find($vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 for $x = $begin to $end step $begin<$end ? 1 : -1 if $vec[$x] = $data Then return $x Next return -1 EndFunc func _Vector_rBegin($vec) if not IsArray($vec) then return -1 return UBound($vec)-1 EndFunc Func _Vector_Begin($vec,$Is_Vector=True) if not IsArray($vec) then return -1 return $Is_Vector ? 1 : 0 EndFunc func _Vector_rEnd($vec,$Is_Vector=True) if not IsArray($vec) then return -1 return $Is_Vector ? 1 : 0 EndFunc func _Vector_End($vec) if not IsArray($vec) then return -1 return UBound($vec)-1 EndFunc func _Display_Vector($vec) if not IsArray($vec) then return -1 _ArrayDisplay($vec) EndFunc func _Create_Vector($elements=0,$data="",$Is_Vector=True) dim $vector[$elements+$Is_Vector] if $Is_Vector then $vector[0]=$elements if $data<>"" Then for $x=_Vector_Begin($vector,$Is_Vector) to _Vector_End($vector) $vector[$x]=$data Next EndIf Return $vector EndFunc Func _Vector_Erase(ByRef $vec,$element,$Is_Vector=True) if not IsArray($vec) then return -1 _ArrayDelete($vec,$element) if $Is_Vector then $vec[0]-=1 EndFunc func _Vector_Sort(ByRef $vec,$ascending=True,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf _ArraySort($vec,Not $ascending,$begin,$end) if not $ascending Then _Vector_Reverse($vec,$Is_Vector,$begin,$end) EndFunc func _Vector_Min(ByRef $vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 $min=$vec[$begin] for $x=$begin to $end step $begin<$end ? 1 : -1 if $vec[$x]<$min then $min=$vec[$x] Next return $min EndFunc func _Vector_Max(ByRef $vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 $max=$vec[$begin] for $x=$begin to $end step $begin<$end ? 1 : -1 if $vec[$x]>$max then $max=$vec[$x] Next return $max EndFunc func _Vector_All_Of(ByRef $vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 for $x=$begin to $end step $begin<$end ? 1 : -1 if $vec[$x]<>$data then Return False Next return True EndFunc func _Vector_Any_Of(ByRef $vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 for $x=$begin to $end step $begin<$end ? 1 : -1 if $vec[$x]=$data then Return True Next return False EndFunc func _Vector_Is_Unique(ByRef $vec,$it,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$it,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 for $x=$begin to $end step $begin<$end ? 1 : -1 if $vec[$it]=$vec[$x] and $x<>$it Then return False Next return True EndFunc func _Vector_Is_Permutation(ByRef $vec1, ByRef $vec2,$Is_Vector=True,$begin1=_Vector_Begin($vec1,$Is_Vector),$end1=_Vector_End($vec1),$begin2=_Vector_Begin($vec2,$Is_Vector),$end2=_Vector_End($vec2)) ;could probably add ranges... if Not IsArray($vec1) or Not _Vector_Is_It_Inbounds($vec1,$begin1,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec1,$end1,$Is_Vector) then return False if Not IsArray($vec2) or Not _Vector_Is_It_Inbounds($vec2,$begin2,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec2,$end2,$Is_Vector) then return False if _Vector_Size($vec1)<>_Vector_Size($vec2) then return False if $begin1>$end1 then $temp=$begin1 $begin1=$end1 $end1=$temp EndIf if $begin2>$end2 then $temp=$begin2 $begin2=$end2 $end2=$temp EndIf $temp1=$vec1 $temp2=$vec2 _Vector_Sort($temp1,True,$Is_Vector,$begin1,$end1) _Vector_Sort($temp2,True,$Is_Vector,$begin2,$end2) for $x=$begin1 to $end1 if $temp1[$x]<>$temp2[$x] then return False Next return True EndFunc func _Vector_Shuffle(ByRef $vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 for $x=$begin to $end-1 _Vector_Swap($vec,$x,Random($x+1,$end,1),$Is_Vector) _Vector_Rotate($vec,Random(1,5,1),Random(0,1,1),$Is_Vector,$begin,$end) Next EndFunc func _Vector_BitShift(ByRef $vec,$moves=1,$right=True,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf $temp=_Create_Vector(_Vector_Distance($vec,$Is_Vector,$begin,$end),"",$Is_Vector) _Vector_Move($vec,$temp,$Is_Vector,$begin,$end) if $right Then for $x=0 to $moves _Vector_PushFront($temp,0,$Is_Vector) _Vector_PopBack($temp,$Is_Vector) Next Else for $x=0 to $moves _Vector_PushBack($temp,0,$Is_Vector) _Vector_PopFront($temp,$Is_Vector) Next EndIf for $x=$begin to $end $vec[$x]=$temp[$x] Next EndFunc func _Vector_Rotate(ByRef $vec,$moves=1,$right=True,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf $temp=_Create_Vector(_Vector_Distance($vec,$Is_Vector,$begin,$end),"",$Is_Vector) _Vector_Move($vec,$temp,$Is_Vector,$begin,$end) if $right Then for $x=1 to $moves _Vector_PushFront($temp,$temp[_Vector_End($temp)],$Is_Vector) _Vector_PopBack($temp) Next Else for $x=1 to $moves _Vector_PushBack($temp,$temp[_Vector_Begin($temp,$Is_Vector)]) _Vector_PopFront($temp,$Is_Vector) Next EndIf for $x=$Is_Vector to _Vector_End($temp) $vec[$begin + $x-$Is_Vector]=$temp[$x] Next EndFunc func _Vector_Find_Next_It($vec,$it,$Is_Vector=True,$begin=$it,$end=_Vector_End($vec)) if not IsArray($vec) or not _Vector_Is_It_Inbounds($vec,$it,$Is_Vector) or not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf return _Vector_Find($vec,$vec[$it],$Is_Vector,$begin,$end) EndFunc func _Vector_Find_Next($vec,$data,$Is_Vector,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf $it=_Vector_Find($vec,$data,$Is_Vector,$begin,$end) if $it=-1 then return -1 return _Vector_Find_Next_It($vec,$it,$begin,$end) EndFunc func _Vector_Reverse(ByRef $vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf while $begin<$end _Vector_Swap($vec,$begin,$end,$Is_Vector) $begin+=1 $end-=1 WEnd EndFunc func _Vector_Permutation_Next(ByRef $vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 if $begin>$end Then $temp=$begin $begin=$end $end=$temp EndIf if _Vector_Distance($vec,$Is_Vector,$begin,$end)<2 then return if _Vector_Distance($vec,$Is_Vector,$begin,$end)=2 Then _Vector_Swap($vec,$begin,$end,$Is_Vector) Return Else for $x=$end to $begin step -1 $change=False if $x+1< $end+1 and $vec[$x]<$vec[$x+1] then for $y=$end to $x+1 step -1 if $vec[$x]<$vec[$y] Then _Vector_Swap($vec,$x,$y,$Is_Vector) _Vector_Reverse($vec,$Is_Vector,$x+1,$end) $change=True ExitLoop EndIf Next EndIf if $change Then ExitLoop Next if Not $change then _Vector_Reverse($vec,$Is_Vector,$begin,$end) EndIf EndFunc Func _Vector_Permutation_Prev(ByRef $vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 if _Vector_Distance($vec,$Is_Vector,$begin,$end)<2 then return if $begin>$end Then $temp=$begin $begin=$end $end=$temp EndIf if _Vector_Distance($vec,$Is_Vector,$begin,$end)=2 Then _Vector_Swap($vec,$begin,$end,$Is_Vector) Return Else for $x=$end to $begin step -1 $change=False if $x+1<$end+1 and $vec[$x]>$vec[$x+1] then for $y=$end to $x+1 step -1 if $vec[$x]>$vec[$y] Then _Vector_Swap($vec,$x,$y,$Is_Vector) _Vector_Reverse($vec,$Is_Vector,$x+1,$end) $change=True ExitLoop EndIf Next EndIf if $change Then ExitLoop Next if Not $change then _Vector_Reverse($vec,$Is_Vector,$begin,$end) EndIf EndFunc func _Vector_String_To_Vec($string,$delimiter="",$Is_Vector=True) ;needs tested if Not IsArray($string) Then Return StringSplit($string,$delimiter) $vec=_Create_Vector(_Vector_Size($string,$Is_Vector),"",$Is_Vector) for $x=_Vector_Begin($vec,$Is_Vector) to _Vector_End($vec) $vec[$x]=StringSplit($string[_Vector_Begin($string,$Is_Vector)],$delimiter) Next return $vec EndFunc func _Vector_Vec_To_String($vec,$Is_Vector=True) if Not IsArray($vec) then Return -1 $string="" for $x=_Vector_Begin($vec,$Is_Vector) to _Vector_End($vec) $string&=$vec[$x] Next return $string EndFunc func _Vector_For_Each_Transform($vec, ByRef $destination,$function,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$d_begin=_Vector_Begin($destination,$Is_Vector),$d_end=_Vector_End($destination)) ;Any return Func(*it) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 if not IsArray($destination) or Not _Vector_Is_It_Inbounds($vec,$d_begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$d_end,$Is_Vector) then Return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf if $d_begin>$d_end then $temp=$d_begin $d_begin=$d_end $d_end=$temp EndIf $y=$d_begin for $x=$begin to $end $destination[$y]=$function($vec[$x]) $y+=1 if $y>$d_end then ExitLoop Next EndFunc func _Vector_Count($vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 $count=0 for $x=$begin to $end step $begin<$end ? 1 : -1 if $vec[$x]=$data Then $count+=1 Next return $count EndFunc func _Vector_None_Of($vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then Return -1 for $x=$begin to $end step $begin<$end ? 1 : -1 if $vec[$x]=$data then return False Next Return True EndFunc func _Vector_None_Of_UPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL UPred(*it) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 for $x=$begin to $end step $begin<$end ? 1 : -1 if $pFunction($vec[$x]) then return False Next Return True EndFunc func _Vector_None_Of_BiPred($vec,$pFunction,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL UPred(*it,data) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 for $x=$begin to $end step $begin<$end ? 1 : -1 if $pFunction($vec[$x],$data) then return False Next Return True EndFunc ;still not entirely satisfied with this.... like what is the point? func _Vector_For_Each($vec,$Vfunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;void func(*it) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 for $x=$begin to $end step $begin<$end ? 1 : -1 $Vfunction($vec[$x]) Next EndFunc func _Vector_Is_Sorted($vec,$ascending=True,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf if $ascending Then for $x=$begin to $end-1 if $vec[$x]<$vec[$x+1] or $vec[$x]<$vec[$end] or $vec[$x]>$vec[$begin] then Return False Next return True else for $x=$x=$begin to $end-1 if $vec[$x]>$vec[$x+1] or $vec[$x]>$vec[$end] or $vec[$x]<$vec[$begin] then Return False Next Return True EndIf EndFunc func _Vector_Is_Sorted_Until($vec,$ascending=True,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf if $ascending Then for $x=$begin to $end-1 if $vec[$x]<$vec[$x+1] or $vec[$x]<$vec[$end] or $vec[$x]>$vec[$begin] then Return $x Next return _Vector_End($vec) else for $x=$begin to $end-1 if $vec[$x]>$vec[$x+1] or $vec[$x]>$vec[$end] or $vec[$x]<$vec[$begin] then Return $x Next Return _Vector_End($vec) EndIf EndFunc func _Vector_Partial_Sort(ByRef $vec,$ascending=True,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf _Vector_Sort($vec,$ascending,$Is_Vector,$begin,$end) EndFunc func _Vector_Min_It($vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf $minIt=$begin $min=$vec[$begin] for $x=$begin to $end if $vec[$x]<$min then $min=$vec[$x] $minIt=$x EndIf Next return $minIt EndFunc func _Vector_Max_It($vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf $maxIt=$begin $max=$vec[$begin] for $x=$begin to $end if $vec[$x]>$max then $max=$vec[$x] $maxIt=$x EndIf Next return $maxIt EndFunc func _Vector_Is_Adjacent_Unique($vec,$data="",$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf for $x=$begin to $end-1 if $data<>"" and $vec[$x]=$data and $data=$vec[$x+1] then Return False ElseIf $data="" and $vec[$x]=$vec[$x+1] Then Return False EndIf Next Return True EndFunc ;this could be messed with Func _Vector_Adjacent_Unique(ByRef $vec,$data="",$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf Do $change=false for $x=$begin to $end-1 if $data<>"" and $vec[$x]=$data and $data=$vec[$x+1] then _Vector_Erase($vec,$x+1,$Is_Vector) $change=True $end-=1 ExitLoop ElseIf $data="" and $vec[$x]=$vec[$x+1] Then _Vector_Erase($vec,$x+1,$Is_Vector) $change=True $end-=1 ExitLoop EndIf Next Until $change=false EndFunc func _Vector_Min_Max($vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf dim $min_max[2] $min_max[0]=_Vector_Min($vec,$Is_Vector,$begin,$end) $min_max[1]=_Vector_Max($vec,$Is_Vector,$begin,$end) Return $min_max EndFunc func _Vector_Min_Max_It($vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf Dim $min_maxIt[2] $min_maxIt[0]=_Vector_Min_It($vec,$Is_Vector,$begin,$end) $min_maxIt[1]=_Vector_Max_It($vec,$Is_Vector,$begin,$end) Return $min_maxIt EndFunc func _Vector_Heap($vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf dim $temp[Ceiling((_Vector_Distance($vec,$Is_Vector,$begin,$end)-3)/2)+1][3] $z=$begin for $y=0 to UBound($temp)-1 for $x=0 to 2 if $z>$end then $temp[$y][$x]=0 ElseIf $y=0 Then $temp[$y][$x]=$vec[$z] $z+=1 ElseIf $y<>0 and $x<>0 Then $temp[$y][$x]=$vec[$z] $z+=1 EndIf Next Next Return $temp EndFunc func _Vector_Is_Heap($heap) if Not IsArray($heap) or UBound($heap,2)<>3 then Return False Return True EndFunc func _Vector_Heap_Sort(ByRef $heap) if Not _Vector_Is_Heap($heap) then return -1 $flip=True Do $sub=0 $change=False for $x=0 to UBound($heap)-1 $sub+=$flip $flip=Not $flip ;~ if $x-$sub-1<0 then ExitLoop if $x>0 and mod($x,2)<>0 Then $heap[$x][0]=$heap[$x-$sub][1] ElseIf $x>1 Then $heap[$x][0]=$heap[$x-$sub][2] EndIf if $heap[$x][1]>$heap[$x][0] and $heap[$x][1]>$heap[$x][2] Then $temp=$heap[$x][1] $heap[$x][1]=$heap[$x][0] $heap[$x][0]=$temp $change=True elseif $heap[$x][2]>$heap[$x][0] and $heap[$x][2]>$heap[$x][1] Then $temp=$heap[$x][2] $heap[$x][2]=$heap[$x][0] $heap[$x][0]=$temp $change=True EndIf if $change and $x>0 and mod($x,2)<>0 Then $heap[$x-$sub][1]=$heap[$x][0] ElseIf $change and $x>1 Then $heap[$x-$sub][2]=$heap[$x][0] EndIf Next Until $change=False ;~ for $x=1 to UBound($heap)-1 ;~ $heap[$x][0]="" ;~ Next EndFunc func _Vector_Display_Heap_Sample($heap) if Not _Vector_Is_Heap($heap) then return -1 $width=(Log(UBound($heap))*2)*7 $height=UBound($heap)*7 dim $temp[$height][$width] $s=floor($width/2) $down=0 dim $spots[2] $flip=True dim $spotsN[4] for $y=0 to UBound($heap)-1 if $y=0 Then $temp[0][$s]=$heap[0][0] $temp[$y+2][$s-3]=$heap[$y][1] $temp[$y+2][$s+3]=$heap[$y][2] $spots[0]=$s-6 $spots[1]=$s+6 $down+=4 else for $q=0 to UBound($spots)-1 if $y+$q >UBound($heap)-1 then ExitLoop $temp[$down][$spots[$q]]=$heap[$y+$q][0] $n=$spots[$q] $temp[$down+2][$n-($flip ? 2 : 1)]=$heap[$y+$q][1] $temp[$down+2][$n+($flip ? 2 : 1)]=$heap[$y+$q][2] $spotsN[$q*2]=$n-($flip ? 2 : 1) $spotsN[$q*2+1]=$n+($flip ? 2 : 1) Next $flip=not $flip $y+=UBound($spots)-1 ReDim $spots[UBound($spotsN)] for $u=0 to UBound($spots)-1 $spots[$u]=$spotsN[$u] Next ReDim $spotsN[UBound($spots)*2] $down+=4 EndIf Next _Display_Vector($temp) EndFunc func _Vector_All_Of_UPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL UPred(*it) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf for $x=$begin to $end if not $pFunction($vec[$x]) then Return False Next return True EndFunc ;not sure about heap func _Vector_Make_Heap_Pred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL Pred(*itFirst,*itLast) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf $temp=_Create_Vector() for $x=$begin to $end _Vector_PushBack($temp,$vec[$x]) Next $tbegin=_Vector_Begin($temp) $tend=_Vector_End($temp) Do if Not $pFunction($temp[$tbegin],$temp[$tend]) Then _Vector_Swap($vec,$temp[$tbegin],$temp[$tend]) EndIf $tbegin+=1 $tend-=1 Until $tbegin>=$tend Return $temp EndFunc ;;;.....................????? func _Vector_Sort_Quick(ByRef $vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin>$end then $temp=$begin $begin=$end $end=$temp EndIf if $begin>=$end then Return if $vec[$begin]>$vec[$end] Then _Vector_Swap($vec,$begin,$end,$Is_Vector) _Vector_Sort_Quick($vec,$Is_Vector,$begin+1,$end-1) EndFunc func _Vector_PopHeap(ByRef $vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if Not IsArray($vec) then return -1 ;add checks $maxIt=_Vector_Max_It($vec,$Is_Vector,$begin,$end) _Vector_PushBack($vec,$vec[$maxIt],$Is_Vector) _Vector_Erase($vec,$maxIt,$Is_Vector) EndFunc Func _Vector_PushHeap(ByRef $vec,$data,$Is_Vector=True) ;this might need messed with, not supposed to include the pushback if Not IsArray($vec) then return -1 ;add checks _Vector_PushBack($vec,$data,$Is_Vector) _Vector_Sort_Quick($vec,$Is_Vector) EndFunc Func _Vector_PushHeap_Pred(ByRef $vec,$data,$pFunction,$Is_Vector=True) ; BOOL Pred(*itFirst,*itLast) if Not IsArray($vec) then return -1 ;add checks _Vector_PushBack($vec,$data,$Is_Vector) $begin=$Is_Vector ? _Vector_Begin($vec) : 0 $end=_Vector_End($vec) Do if Not $pFunction($vec[$begin],$vec[$end]) Then _Vector_Swap($vec,$begin,$end,$Is_Vector) EndIf $begin+=1 $end-=1 Until $begin>=$end EndFunc func _Vector_Sort_Heap_Pred(ByRef $vec,$pFunction,$ascending=True,$Is_Vector=True,$begin= _Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL Pred(*it,*++it) if Not IsArray($vec) then return -1 ;add checks Do $change=False For $x=$begin to $end-1 if Not $pFunction($vec[$x],$vec[$x+1]) Then _Vector_Swap($vec,$x,$x+1,$Is_Vector) $change=True EndIf Next Until $change=False if Not $ascending then _Vector_Reverse($vec,$Is_Vector) EndFunc func _Vector_Copy_UPred($vec,$pFunction,$Is_Vector=True,$begin= _Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;Bool UPred(*it) if Not IsArray($vec) then return -1 ;add checks $temp=_Create_Vector() for $x=$begin to $end if $pFunction($vec[$x]) Then _Vector_PushBack($temp,$vec[$x]) EndIf Next Return $temp EndFunc func _Vector_Sort_Nth_Element(ByRef $vec,$it,$ascending=True,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if Not IsArray($vec) then return -1 ;add checks $temp=$vec _Vector_Partial_Sort($temp,$begin,$end,$ascending,$Is_Vector) for $x=$begin to $end if $vec[$it] = $temp[$x] and $it<>$x Then _Vector_Swap($vec,$x,$it,$Is_Vector) ExitLoop EndIf Next for $x=$begin to $it-1 if $vec[$x]>$vec[$it] Then for $y=$it+1 to $end if $vec[$y]<=$vec[$it] Then _Vector_Swap($vec,$x,$y,$Is_Vector) ExitLoop EndIf Next EndIf Next EndFunc func _Vector_For_Each_Nth($vec,$Vfunction,$count,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector), $end=_Vector_End($vec)) ;any return func(*it) ;more checks if Not IsArray($vec) then Return -1 if $begin<$end Then for $x=0 to $count-1 if $begin+$x>$end then ExitLoop $vec[$begin+$x]=$Vfunction($vec[$begin+$x]) Next Else for $x=0 to $count-1 if $begin-$x<$end then ExitLoop $vec[$begin-$x]=$Vfunction($vec[$begin-$x]) Next EndIf EndFunc func _Vector_Merge_Sort($vec1,$vec2,$Is_Vector=True,$begin1=_Vector_Begin($vec1,$Is_Vector),$end1=_Vector_End($vec1),$begin2=_Vector_Begin($vec2,$Is_Vector),$end2=_Vector_End($vec2)) if Not IsArray($vec1) or Not IsArray($vec2) then Return -1 _Vector_Partial_Sort($vec1,$begin1,$end1,True,$Is_Vector) _Vector_Partial_Sort($vec2,$begin2,$end2,True,$Is_Vector) while UBound($vec2) > ($Is_Vector ? 1 : 0) for $x=$begin1 to $end1-1 if $vec2[$begin2]<$vec1[$x] and $x=$begin1 and $begin1=($Is_Vector ? 1 : 0) Then _Vector_PushFront($vec1,$vec2[$begin2],$Is_Vector) _Vector_Erase($vec2,$begin2,$Is_Vector) $end1+=1 ExitLoop elseif $vec1[$x]<= $vec2[$begin2] and $vec1[$x+1]>=$vec2[$begin2] Then _Vector_Insert($vec1,$x+1,$vec2[$begin2],$Is_Vector) _Vector_Erase($vec2,$begin2,$Is_Vector) $end1+=1 ExitLoop elseif $x=$end1-1 Then _Vector_PushBack($vec1,$vec2[$begin2],$Is_Vector) _Vector_Erase($vec2,$begin2,$Is_Vector) $end1+=1 ExitLoop EndIf Next WEnd Return $vec1 EndFunc func _Vector_Merge($vec1,$vec2,$Is_Vector=True,$begin1=_Vector_Begin($vec1,$Is_Vector),$end1=_Vector_End($vec1),$begin2=_Vector_Begin($vec2,$Is_Vector),$end2=_Vector_End($vec2)) if Not IsArray($vec1) or Not IsArray($vec2) then Return -1 if $Is_Vector Then $merged=_Create_Vector() Else $merged=_Create_Vector(0,"",False) EndIf for $x=$begin1 to $end1 _Vector_PushBack($merged,$vec1[$x],$Is_Vector) Next for $x=$begin2 to $end2 _Vector_PushBack($merged,$vec2[$x],$Is_Vector) Next return $merged EndFunc func _Vector_Merge_Sort_Quick($vec1,$vec2,$Is_Vector=True,$begin1=_Vector_Begin($vec1,$Is_Vector),$end1=_Vector_End($vec1),$begin2=_Vector_Begin($vec2,$Is_Vector),$end2=_Vector_End($vec2)) if Not IsArray($vec1) or Not IsArray($vec2) then Return -1 if $Is_Vector Then $merged=_Create_Vector() Else $merged=_Create_Vector(0,"",False) EndIf for $x=$begin1 to $end1 _Vector_PushBack($merged,$vec1[$x],$Is_Vector) Next for $x=$begin2 to $end2 _Vector_PushBack($merged,$vec2[$x],$Is_Vector) Next _Vector_Sort_Quick($merged,$Is_Vector,_Vector_Begin($merged,$Is_Vector),_Vector_End($merged)) return $merged EndFunc func _Vector_Merge_Sort_Pred($vec1,$vec2,$pFunction,$Is_Vector=True,$begin1=_Vector_Begin($vec1,$Is_Vector),$end1=_Vector_End($vec1),$begin2=_Vector_Begin($vec2,$Is_Vector),$end2=_Vector_End($vec2));BOOL Pred(*it,*++it) if Not IsArray($vec1) or Not IsArray($vec2) then Return -1 if $Is_Vector Then $merged=_Create_Vector() Else $merged=_Create_Vector(0,"",False) EndIf for $x=$begin1 to $end1 _Vector_PushBack($merged,$vec1[$x],$Is_Vector) Next for $x=$begin2 to $end2 _Vector_PushBack($merged,$vec2[$x],$Is_Vector) Next Do $change=False for $x=_Vector_Begin($merged,$Is_Vector) to _Vector_End($merged)-1 if Not $pFunction($merged[$x],$merged[$x+1]) Then _Vector_Swap($merged,$x,$x+1,$Is_Vector) $change=True EndIf Next Until $change=False return $merged EndFunc func _Create_Vector_Random_Nums($elements=1,$min=0,$max=999999999,$flag=1,$Is_Vector=True) $vector=_Create_Vector($elements,"",$Is_Vector) for $x=_Vector_Begin($vector,$Is_Vector) to _Vector_End($vector) $vector[$x]=Random($min,$max,$flag) Next Return $vector EndFunc func _Vector_Is_Merge($collection,$vec1,$vec2,$Is_Vector=True,$begin1=_Vector_Begin($vec1,$Is_Vector),$end1=_Vector_End($vec1),$begin2=_Vector_Begin($vec2,$Is_Vector),$end2=_Vector_End($vec2)) if Not IsArray($vec1) or Not IsArray($vec2) then Return -1 for $x=$begin1 to $end1 for $y=_Vector_Begin($collection,$Is_Vector) to _Vector_End($collection) if $vec1[$x]=$collection[$y] Then _Vector_Erase($collection,$y,$Is_Vector) ExitLoop ElseIf $y=_Vector_End($collection) then return False EndIf Next Next for $x=$begin2 to $end2 for $y=_Vector_Begin($collection,$Is_Vector) to _Vector_End($collection) if $vec2[$x]=$collection[$y] Then _Vector_Erase($collection,$y,$Is_Vector) ExitLoop ElseIf $y=_Vector_End($collection) and _Vector_Size($collection,$Is_Vector)<>0 then return False EndIf Next Next Return True EndFunc Func _Vector_Unique(ByRef $vec,$data="",$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if Not IsArray($vec) then return -1 ;add checks $found=false if $data<>"" Then for $x=$begin to $end if Not _Vector_Is_It_Inbounds($vec,$x,$Is_Vector) then ExitLoop if $vec[$x]=$data and Not $found then $found=True ElseIf $vec[$x]=$data and $found then _Vector_Erase($vec,$x,$Is_Vector) $x-=1 EndIf Next Else for $y=$begin to $end-1 for $x=$y+1 to $end if Not _Vector_Is_It_Inbounds($vec,$y,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$x,$Is_Vector) then ExitLoop if $vec[$x]=$vec[$y] then _Vector_Erase($vec,$y,$Is_Vector) $y-=1 EndIf Next Next EndIf EndFunc func _Vector_For_Each_Transform_Nth(ByRef $vec,$function,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;Any return Func(*it) if Not IsArray($vec) then Return -1 for $x=$begin to $end $vec[$x]=$function($vec[$x]) Next EndFunc func _Vector_Is_It_Inbounds(ByRef $vec,$it,$Is_Vector=True) if $it<_Vector_Begin($vec,$Is_Vector) or $it>_Vector_Size($vec,$Is_Vector) Then Return False Else Return True EndIf EndFunc func _Vector_Any_Of_UPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL UPred(*it) if not IsArray($vec) then Return -1 ;add checks for $x=$begin to $end if $pFunction($vec[$x]) then Return True Next return False EndFunc func _Vector_Find_All($vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 $temp=_Create_Vector(0,"",$Is_Vector) $found=False for $x = $begin to $end if $vec[$x] = $data Then _Vector_PushBack($temp,$x,$Is_Vector) $found=True EndIf Next return $found ? $temp : -1 EndFunc func _Vector_Find_All_UPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL UPred(*it) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 $temp=_Create_Vector(0,"",$Is_Vector) $found=False for $x = $begin to $end if $pFunction($vec[$x]) Then _Vector_PushBack($temp,$x,$Is_Vector) $found=True EndIf Next return $found ? $temp : -1 EndFunc func _Create_Vector_Random_Letters($elements=1,$uppercase=False,$upper_and_lower=False,$Is_Vector=True) $vector=_Create_Vector($elements,"",$Is_Vector) for $x=_Vector_Begin($vector,$Is_Vector) to _Vector_End($vector) if Not $uppercase and Not $upper_and_lower Then $vector[$x]=Chr(Random(97,122,1)) ElseIf $uppercase Then $vector[$x]=Chr(Random(65,90,1)) ElseIf $upper_and_lower Then if Random(0,1,1) Then $vector[$x]=Chr(Random(97,122,1)) Else $vector[$x]=Chr(Random(65,90,1)) EndIf EndIf Next Return $vector EndFunc func _Create_Vector_Random_Strings($elements=1,$min_length=8,$max_lenghth=15,$only_letters=True,$uppercase=False,$upper_and_lower=False,$Is_Vector=True) $vector=_Create_Vector($elements,"",$Is_Vector) for $x=_Vector_Begin($vector,$Is_Vector) to _Vector_End($vector) $temp="" for $y=0 to Random($min_length,$max_lenghth,1) if Not $only_letters Then if Not $uppercase and Not $upper_and_lower Then if Random(0,1,1) Then $temp&=Chr(Random(91,126,1)) Else $temp&=Chr(Random(32,64,1)) EndIf ElseIf $uppercase Then if Mod(Random(1,10,1),4)=0 Then $temp&=Chr(Random(123,126,1)) Else $temp&=Chr(Random(32,96,1)) EndIf ElseIf $upper_and_lower Then $temp&=Chr(Random(32,126,1)) EndIf Else if Not $uppercase and Not $upper_and_lower Then $temp&=Chr(Random(97,122,1)) ElseIf $uppercase Then $temp&=Chr(Random(65,90,1)) ElseIf $upper_and_lower Then if Random(0,1,1) Then $temp&=Chr(Random(97,122,1)) Else $temp&=Chr(Random(65,90,1)) EndIf EndIf EndIf Next $vector[$x]=$temp Next Return $vector EndFunc func _Vector_Count_UPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL UPred(*it)) if Not IsArray($vec) then return -1 $count=0 for $x=$begin to $end if $pFunction($vec[$x]) Then $count+=1 Next return $count EndFunc func _Vector_Mismatch($vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$rBegin=_Vector_rBegin($vec)) dim $mismatch[2] for $x=$begin to $end if $vec[$x]<>$vec[$rBegin] Then $mismatch[0]=$x $mismatch[1]=$rBegin Return $mismatch EndIf $rBegin-=1 Next return -1 EndFunc func _Vector_Mismatch_Pred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$rBegin=_Vector_rBegin($vec)) dim $mismatch[2] for $x=$begin to $end if Not $pFunction($vec[$x],$vec[$rBegin]) Then $mismatch[0]=$x $mismatch[1]=$rBegin Return $mismatch EndIf $rBegin-=1 Next return -1 EndFunc Func _Vector_Fill(ByRef $vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks!!!! for $x=$begin to $end $vec[$x]=$data Next EndFunc Func _Vector_Remove(ByRef $vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks!!! for $x=$begin to $end if Not _Vector_Is_It_Inbounds($vec,$x,$Is_Vector) then ExitLoop if $vec[$x]=$data Then _Vector_Erase($vec,$x,$Is_Vector) $x-=1 $end-=1 EndIf Next Return 1 EndFunc Func _Vector_Remove_UPred(ByRef $vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks!!! for $x=$begin to $end if Not _Vector_Is_It_Inbounds($vec,$x,$Is_Vector) then ExitLoop if $pFunction($vec[$x]) Then _Vector_Erase($vec,$x,$Is_Vector) $x-=1 $end-=1 EndIf Next Return 1 EndFunc func _Vector_Replace(ByRef $vec,$old_data,$new_data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks... for $x=$begin to $end if $vec[$x]=$old_data Then $vec[$x]=$new_data Next Return 1 EndFunc func _Vector_Replace_UPred(ByRef $vec,$pFunction,$new_data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks... for $x=$begin to $end if $pFunction($vec[$x]) Then $vec[$x]=$new_data Next Return 1 EndFunc func _Vector_Swap_Ranges(ByRef $vec1, ByRef $vec2,$Is_Vector=True,$begin1=_Vector_Begin($vec1,$Is_Vector),$end1=_Vector_End($vec1),$begin2=_Vector_Begin($vec2,$Is_Vector)) ;checks... for $x=$begin1 to $end1 if Not _Vector_Is_It_Inbounds($vec2,$begin2,$Is_Vector) Then ExitLoop $temp=$vec1[$x] $vec1[$x]=$vec2[$begin2] $vec2[$begin2]=$temp $begin2+=1 Next EndFunc func _Vector_Sample($vec,$elements=1,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks dim $sample[$elements] for $x=0 to $elements $sample[$x]=$vec[Random($begin,$end,1)] Next Return $sample EndFunc func _Vector_Partition_UPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks ;bloody brilliant!! $part=_Create_Vector(0,"",$Is_Vector) _Vector_PushBack($part,_Create_Vector(0,"",$Is_Vector),$Is_Vector) _Vector_PushBack($part,_Create_Vector(0,"",$Is_Vector),$Is_Vector) for $x=$begin to $end if $pFunction($vec[$x]) Then _Vector_PushBack($part[$Is_Vector],$vec[$x],$Is_Vector) Else _Vector_PushBack($part[$Is_Vector+1],$vec[$x],$Is_Vector) EndIf Next return $part EndFunc func _Vector_Is_Partitioned_UPred($part,$pFunction,$Is_Vector=True) ;checks... ;this was a pita if Not IsArray($part) or _Vector_Size($part,$Is_Vector)<>2 or Not IsArray($part[$Is_Vector]) or Not IsArray($part[$Is_Vector+1]) then return False $merged=_Vector_Merge($part[$Is_Vector],$part[$Is_Vector+1],$Is_Vector) $part2=_Vector_Partition_UPred($merged,$pFunction,$Is_Vector) if _Vector_Is_Permutation($part[$Is_Vector],$part2[$Is_Vector],$Is_Vector) and _Vector_Is_Permutation($part[$Is_Vector+1],$part2[$Is_Vector+1],$Is_Vector) Then Return True Return False EndFunc func _Vector_Partition($vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks $part=_Create_Vector(0,"",$Is_Vector) _Vector_PushBack($part,_Create_Vector(0,"",$Is_Vector),$Is_Vector) _Vector_PushBack($part,_Create_Vector(0,"",$Is_Vector),$Is_Vector) for $x=$begin to $end if $vec[$x]<$data Then _Vector_PushBack($part[$Is_Vector],$vec[$x],$Is_Vector) Else _Vector_PushBack($part[$Is_Vector+1],$vec[$x],$Is_Vector) EndIf Next return $part EndFunc func _Vector_Partition_Sort_UPred(ByRef $part,$pFunction,$Is_Vector=True) if Not IsArray($part) or _Vector_Size($part,$Is_Vector)<>2 or Not IsArray($part[$Is_Vector]) or Not IsArray($part[$Is_Vector+1]) then return False $merged=_Vector_Merge($part[$Is_Vector],$part[$Is_Vector+1],$Is_Vector) $part=_Vector_Partition_UPred($merged,$pFunction,$Is_Vector) EndFunc func _Vector_Any_Of_BiPred($vec,$data,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL BiPred(*it, data) if not IsArray($vec) then Return -1 ;add checks for $x=$begin to $end if $pFunction($vec[$x],$data) then Return True Next return False EndFunc func lb_pred($x,$y) ;##internal if $x>=$y then Return True return False EndFunc func _Vector_LowerBound(ByRef $vec,$data,$is_sorted=false,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks if Not _Vector_Any_Of_BiPred($vec,$data,lb_pred,$Is_Vector,$begin,$end) then Return -1 if Not $is_sorted Then $part=_Vector_Partition($vec,$data,$Is_Vector,$begin,$end) $vec=_Vector_Merge($part[$Is_Vector],$part[$Is_Vector+1],$Is_Vector) EndIf for $x=$begin to $end if $vec[$x]>=$data then Return $x Next Return -1 EndFunc ;below either needs sorted or i need to create a BiPred Sort.....this still needs alot of work....tired func _Vector_LowerBound_BiPred(ByRef $vec,$data,$pFunction,$is_sorted=false,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;Bool BiPred(*it, data) ;checks ; if Not _Vector_Any_Of_BiPred($vec,$data,$pFunction,$Is_Vector,$begin,$end) then Return -1 for $x=$begin to $end if $pFunction($vec[$x],$data) then Return $x Next Return -1 EndFunc func ub_pred($x,$y) ;##internal## if $x>$y then Return True return False EndFunc func _Vector_UpperBound(ByRef $vec,$data,$is_sorted=False,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks if Not _Vector_Any_Of_BiPred($vec,$data,ub_pred,$Is_Vector,$begin,$end) then Return -1 if Not $is_sorted Then $part=_Vector_Partition($vec,$data,$Is_Vector,$begin,$end) $vec=_Vector_Merge($part[$Is_Vector],$part[$Is_Vector+1],$Is_Vector) EndIf for $x=$begin to $end if $vec[$x]>$data then Return $x Next Return -1 EndFunc ;place holder func _Vector_UpperBound_BiPred(ByRef $vec,$data,$is_sorted=False,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks EndFunc func _Vector_Iota(ByRef $vec,$data,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks... $y=0 if $begin<$end Then for $x=$begin to $end $vec[$x]=$data+$y $y+=1 Next Else for $x=$begin to $end step -1 $vec[$x]=$data+$y $y+=1 Next EndIf EndFunc func _Vector_Accumulate($vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks $sum=0 for $x=$begin to $end $sum+=$vec[$x] Next EndFunc Func _Vector_Adjacent_Find($vec,$data="",$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks if $begin<$end Then if $data="" Then for $x=$begin to $end-1 if $vec[$x]=$vec[$x+1] then Return $x Next Return -1 Else for $x=$begin to $end-1 if $vec[$x]=$data and $vec[$x]=$vec[$x+1] then Return $x Next Return -1 EndIf Else if $data="" Then for $x=$end-1 to $begin step -1 if $vec[$x]=$vec[$x+1] then Return $x Next Return -1 Else for $x=$end-1 to $begin step -1 if $vec[$x]=$data and $vec[$x]=$vec[$x+1] then Return $x Next Return -1 EndIf EndIf EndFunc Func _Vector_Adjacent_Find_BiPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;Bool BiPred(*it,*it++) ;checks if $begin<$end Then for $x=$begin to $end-1 if $pFunction($vec[$x],$vec[$x+1]) then Return $x Next Else for $x=$end-1 to $begin step -1 if $pFunction($vec[$x],$vec[$x+1]) then Return $x Next EndIf Return -1 EndFunc func _Vector_Count_BiPred($vec,$data,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL BiPred(*it,data) if Not IsArray($vec) then return -1 $count=0 for $x=$begin to $end if $pFunction($vec[$x],$data) Then $count+=1 Next return $count EndFunc func _Vector_Find_If_UPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;Bool UPred(*it) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin<$end Then for $x = $begin to $end if $pFunction($vec[$x]) Then return $x Next Else for $x = $end to $begin step -1 if $pFunction($vec[$x]) Then return $x Next EndIf return -1 EndFunc func _Vector_Find_If_BiPred($vec,$data,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL BiPred(*it,data) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin<$end Then for $x = $begin to $end if $pFunction($vec[$x],$data) Then return $x Next Else for $x = $end to $begin step -1 if $pFunction($vec[$x],$data) Then return $x Next EndIf return -1 EndFunc func _Vector_Find_If_Not_UPred($vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;Bool UPred(*it) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin<$end Then for $x = $begin to $end if Not $pFunction($vec[$x]) Then return $x Next Else for $x = $end to $begin step -1 if Not $pFunction($vec[$x]) Then return $x Next EndIf return -1 EndFunc func _Vector_Find_If_Not_BiPred($vec,$data,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;BOOL BiPred(*it,data) if not IsArray($vec) or Not _Vector_Is_It_Inbounds($vec,$begin,$Is_Vector) or Not _Vector_Is_It_Inbounds($vec,$end,$Is_Vector) then return -1 if $begin<$end Then for $x = $begin to $end if Not $pFunction($vec[$x],$data) Then return $x Next Else for $x = $end to $begin step -1 if Not $pFunction($vec[$x],$data) Then return $x Next EndIf return -1 EndFunc ;Finds the last occurrence of a sequence func _Vector_Find_End($vec,$s_vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;checks Return _Vector_Search($vec,$s_vec,$Is_Vector,$end,$begin,$s_end,$s_begin) EndFunc func _Vector_Find_End_BiPred($vec,$s_vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;BOOL BiPred(*it,*s_it) ;checks Return _Vector_Search_BiPred($vec,$s_vec,$pFunction,$Is_Vector,$end,$begin,$s_end,$s_begin) EndFunc func _Vector_Find_End_TriPred($vec,$s_vec,$data,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;BOOL TriPred(*it,*s_it,data) ;checks Return _Vector_Search_TriPred($vec,$s_vec,$data,$pFunction,$Is_Vector,$end,$begin,$s_end,$s_begin) EndFunc func _Vector_Find_First_Of($vec,$s_vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;checks if $begin<$end and $s_begin<$s_end Then for $y=$begin to $end for $x=$s_begin to $s_end if $s_vec[$x]=$vec[$y] Then return $y Next Next elseif $begin<$end and $s_begin>$s_end Then for $y=$begin to $end for $x=$s_begin to $s_end step -1 if $s_vec[$x]=$vec[$y] Then return $y Next Next elseif $begin>$end and $s_begin<$s_end Then for $y=$begin to $end step -1 for $x=$s_begin to $s_end if $s_vec[$x]=$vec[$y] Then return $y Next Next elseif $begin>$end and $s_begin>$s_end Then for $y=$begin to $end step -1 for $x=$s_begin to $s_end step -1 if $s_vec[$x]=$vec[$y] Then return $y Next Next EndIf Return -1 EndFunc func _Vector_Find_First_Of_BiPred($vec,$s_vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;Bool BiPred(*it,*s_it) ;checks if $begin<$end and $s_begin<$s_end Then for $y=$begin to $end for $x=$s_begin to $s_end if $pFunction($vec[$y],$s_vec[$x]) Then return $y Next Next elseif $begin<$end and $s_begin>$s_end Then for $y=$begin to $end for $x=$s_begin to $s_end step -1 if $pFunction($vec[$y],$s_vec[$x]) Then return $y Next Next elseif $begin>$end and $s_begin<$s_end Then for $y=$begin to $end step -1 for $x=$s_begin to $s_end if $pFunction($vec[$y],$s_vec[$x]) Then return $y Next Next elseif $begin>$end and $s_begin>$s_end Then for $y=$begin to $end step -1 for $x=$s_begin to $s_end step -1 if $pFunction($vec[$y],$s_vec[$x]) Then return $y Next Next EndIf Return -1 EndFunc func _Vector_Find_First_Of_TriPred($vec,$s_vec,$data,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;Bool BiPred(*it,*s_it,data) ;checks if $begin<$end and $s_begin<$s_end Then for $y=$begin to $end for $x=$s_begin to $s_end if $pFunction($vec[$y],$s_vec[$x],$data) Then return $y Next Next elseif $begin<$end and $s_begin>$s_end Then for $y=$begin to $end for $x=$s_begin to $s_end step -1 if $pFunction($vec[$y],$s_vec[$x],$data) Then return $y Next Next elseif $begin>$end and $s_begin<$s_end Then for $y=$begin to $end step -1 for $x=$s_begin to $s_end if $pFunction($vec[$y],$s_vec[$x],$data) Then return $y Next Next elseif $begin>$end and $s_begin>$s_end Then for $y=$begin to $end step -1 for $x=$s_begin to $s_end step -1 if $pFunction($vec[$y],$s_vec[$x],$data) Then return $y Next Next EndIf Return -1 EndFunc ;Finds the first occurrence of a sequence func _Vector_Search($vec,$s_vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;checks if $begin<$end and $s_begin<$s_end Then for $y=$begin to $end-($s_end-$s_begin) if $vec[$y]=$s_vec[$s_begin] Then $z=0 for $x=$y+1 to $end $z+=1 if $vec[$x]<>$s_vec[$s_begin+$z] Then ExitLoop if $z+$s_begin=$s_end and $vec[$x]=$s_vec[$s_begin+$z] Then return $y Next EndIf Next elseif $begin<$end and $s_begin>$s_end Then for $y=$begin to $end-($s_begin-$s_end) if $vec[$y]=$s_vec[$s_end] Then $z=0 for $x=$y+1 to $end $z-=1 if $vec[$x]<>$s_vec[$s_begin+$z] Then ExitLoop if $z+$s_begin=$s_end and $vec[$x]=$s_vec[$s_begin+$z] Then return $y Next EndIf Next elseif $begin>$end and $s_begin<$s_end Then for $y = $begin to $end+($s_end-$s_begin) step -1 if $vec[$y]=$s_vec[$s_begin] Then $z=0 for $x=$y-1 to $end step -1 $z+=1 if $vec[$x]<>$s_vec[$s_begin+$z] Then ExitLoop if $z+$s_begin=$s_end and $vec[$x]=$s_vec[$s_begin+$z] Then return $y Next EndIf Next elseif $begin>$end and $s_begin>$s_end Then for $y = $begin to $end+($s_end-$s_begin) step -1 if $vec[$y]=$s_vec[$s_begin] Then $z=0 for $x=$y-1 to $end step -1 $z-=1 if $vec[$x]<>$s_vec[$s_begin+$z] Then ExitLoop if $z+$s_begin=$s_end and $vec[$x]=$s_vec[$s_begin+$z] Then return $y Next EndIf Next EndIf Return -1 EndFunc func _Vector_Search_BiPred($vec,$s_vec,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;BOOL BiPred(*it,*s_it) ;checks if $begin<$end and $s_begin<$s_end Then for $y=$begin to $end-($s_end-$s_begin) if $pFunction($vec[$y],$s_vec[$s_begin]) Then $z=0 for $x=$y+1 to $end $z+=1 if Not $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then ExitLoop if $z+$s_begin=$s_end and $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then return $y Next EndIf Next elseif $begin<$end and $s_begin>$s_end Then for $y=$begin to $end-($s_begin-$s_end) if $pFunction($vec[$y],$s_vec[$s_begin]) Then $z=0 for $x=$y+1 to $end $z-=1 if Not $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then ExitLoop if $z+$s_begin=$s_end and $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then return $y Next EndIf Next elseif $begin>$end and $s_begin<$s_end Then for $y = $begin to $end+($s_end-$s_begin) step -1 if $pFunction($vec[$y],$s_vec[$s_begin]) Then $z=0 for $x=$y-1 to $end step -1 $z+=1 if Not $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then ExitLoop if $z+$s_begin=$s_end and $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then return $y Next EndIf Next elseif $begin>$end and $s_begin>$s_end Then for $y = $begin to $end+($s_end-$s_begin) step -1 if $pFunction($vec[$y],$s_vec[$s_begin]) Then $z=0 for $x=$y-1 to $end step -1 $z-=1 if Not $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then ExitLoop if $z+$s_begin=$s_end and $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then return $y Next EndIf Next EndIf Return -1 EndFunc func _Vector_Search_TriPred($vec,$s_vec,$data,$pFunction,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$s_begin=_Vector_Begin($s_vec,$Is_Vector),$s_end=_Vector_End($s_vec)) ;BOOL TriPred(*it,*s_it,data) ;checks if $begin<$end and $s_begin<$s_end Then for $y=$begin to $end-($s_end-$s_begin) if $pFunction($vec[$y],$s_vec[$s_begin],$data) Then $z=0 for $x=$y+1 to $end $z+=1 if Not $pFunction($vec[$x],$s_vec[$s_begin+$z],$data) Then ExitLoop if $z+$s_begin=$s_end and $pFunction($vec[$x],$s_vec[$s_begin+$z],$data) Then return $y Next EndIf Next elseif $begin<$end and $s_begin>$s_end Then for $y=$begin to $end-($s_begin-$s_end) if $pFunction($vec[$y],$s_vec[$s_begin],$data) Then $z=0 for $x=$y+1 to $end $z-=1 if Not $pFunction($vec[$x],$s_vec[$s_begin+$z],$data) Then ExitLoop if $z+$s_begin=$s_end and $pFunction($vec[$x],$s_vec[$s_begin+$z],$data) Then return $y Next EndIf Next elseif $begin>$end and $s_begin<$s_end Then for $y = $begin to $end+($s_end-$s_begin) step -1 if $pFunction($vec[$y],$s_vec[$s_begin],$data) Then $z=0 for $x=$y-1 to $end step -1 $z+=1 if Not $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then ExitLoop if $z+$s_begin=$s_end and $pFunction($vec[$x],$s_vec[$s_begin+$z]) Then return $y Next EndIf Next elseif $begin>$end and $s_begin>$s_end Then for $y = $begin to $end+($s_end-$s_begin) step -1 if $pFunction($vec[$y],$s_vec[$s_begin],$data) Then $z=0 for $x=$y-1 to $end step -1 $z-=1 if Not $pFunction($vec[$x],$s_vec[$s_begin+$z],$data) Then ExitLoop if $z+$s_begin=$s_end and $pFunction($vec[$x],$s_vec[$s_begin+$z],$data) Then return $y Next EndIf Next EndIf Return -1 EndFunc func _Vector_Search_N($vec,$count=2,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks if $count<2 then Return $begin if $begin<$end Then for $x=$begin to $end-$count+1 for $y=1 to $count-1 if $vec[$x]<>$vec[$x+$y] then ExitLoop if $y=$count-1 and $vec[$x]=$vec[$x+$y] then Return $x Next Next Else for $x=$begin to $end+$count-1 step -1 for $y=1 to $count-1 if $vec[$x]<>$vec[$x-$y] then ExitLoop if $y=$count-1 and $vec[$x]=$vec[$x-$y] then Return $x Next Next EndIf EndFunc func _Vector_Search_N_UPred($vec,$pFunction,$count=2,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;bool UPred(*it) ;checks if $count<2 then Return $begin if $begin<$end Then for $x=$begin to $end-$count+1 if $pFunction($vec[$x]) Then for $y=1 to $count if not $pFunction($vec[$x+$y]) then ExitLoop if $y=$count and $pFunction($vec[$x+$y]) then Return $x Next EndIf Next Else for $x=$begin to $end+$count-1 step -1 if $pFunction($vec[$x]) Then for $y=1 to $count if $pFunction($vec[$x-$y]) then ExitLoop if $y=$count and $pFunction($vec[$x-$y]) then Return $x Next EndIf Next EndIf EndFunc func _Vector_Search_N_BiPred($vec,$data,$pFunction,$count=2,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;bool BiPred(*it,data) ;checks if $count<2 then Return $begin if $begin<$end Then for $x=$begin to $end-$count+1 if $pFunction($vec[$x],$data) Then for $y=1 to $count if not $pFunction($vec[$x+$y],$data) then ExitLoop if $y=$count and $pFunction($vec[$x+$y],$data) then Return $x Next EndIf Next Else for $x=$begin to $end+$count-1 step -1 if $pFunction($vec[$x],$data) Then for $y=1 to $count if $pFunction($vec[$x-$y],$data) then ExitLoop if $y=$count and $pFunction($vec[$x-$y],$data) then Return $x Next EndIf Next EndIf EndFunc Func _Vector_Move($vec, ByRef $destination,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$d_begin=_Vector_Begin($destination,$Is_Vector),$d_end=_Vector_End($destination)) ;checks if $begin<$end Then $y=0 for $x=$begin to $end if not _Vector_Is_It_Inbounds($destination,$d_begin+$y,$Is_Vector) then ExitLoop $destination[$d_begin+$y]=$vec[$x] $y+=1 Next Else $y=0 for $x=$begin to $end step -1 if not _Vector_Is_It_Inbounds($destination,$d_begin+$y,$Is_Vector) then ExitLoop $destination[$d_begin+$y]=$vec[$x] $y+=1 Next EndIf EndFunc Func _Vector_Move_Backwards($vec, ByRef $destination,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec),$d_begin=_Vector_Begin($destination,$Is_Vector),$d_end=_Vector_End($destination)) ;checks if $begin < $end Then $y=0 for $x = $end to $begin step -1 if not _Vector_Is_It_Inbounds($destination,$d_begin+$y,$Is_Vector) then ExitLoop $destination[$d_begin+$y]=$vec[$x] $y+=1 Next Else $y=0 for $x=$end to $begin if not _Vector_Is_It_Inbounds($destination,$d_begin+$y,$Is_Vector) then ExitLoop $destination[$d_begin+$y]=$vec[$x] $y+=1 Next EndIf EndFunc func _Vector_For_Each_Generate_Ufunc(ByRef $vec,$function,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;Any return Func(*it) if Not IsArray($vec) then Return -1 for $x=$begin to $end $vec[$x]=$function($vec[$x]) Next EndFunc func _Vector_For_Each_Generate_BiFunc(ByRef $vec1,$vec2,$function,$Is_Vector=True,$begin1=_Vector_Begin($vec1,$Is_Vector),$end1=_Vector_End($vec1),$begin2=_Vector_Begin($vec2,$Is_Vector),$end2=_Vector_End($vec2)) ;Any return BiFunc(*it1,*it2) if Not IsArray($vec1) then Return -1 $y=$begin2 for $x=$begin1 to $end1 $vec1[$x]=$function($vec1[$x],$vec2[$y]) $y+=1 if $y>$end2 then Return -1 Next EndFunc func _Vector_Distance($vec,$Is_Vector=True,$begin=_Vector_Begin($vec,$Is_Vector),$end=_Vector_End($vec)) ;checks...grrrr $count=0 for $x=$begin to $end step $begin<$end ? 1 : -1 $count+=1 Next Return $count EndFunc ;bitand bitor, generate,generate_n,fix transform,maybe find_all_bipred ;includes,set_difference,set_intersection,set_symmetric_difference,set_union,equal,lexicographical_compare,lexicographical_compare_three_way ;inner_product,adjacent_difference,partial_sum,reduce,exclusive_scan,inclusive_scan,transfom_reduce,Transform_inclusivescan,transform_exclusivescan ;destroy,destry_n,move_if,move_until,move_backwards_if,move_backwards_until