<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Сравнение массива с массивом]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=13169</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=13169&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Сравнение массива с массивом».]]></description>
		<lastBuildDate>Fri, 06 Mar 2020 23:23:20 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=138372#p138372</link>
			<description><![CDATA[<p>Всё правильно, но только в моём примере элементы не равны. В первом массиве просто нет второго элемента, во втором он пустой, это не одно и то же.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 06 Mar 2020 23:23:20 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=138372#p138372</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=138371#p138371</link>
			<description><![CDATA[<p>В моём случае эквивалентными массивами являются массивы, элементы которых соответственно равны.</p>]]></description>
			<author><![CDATA[null@example.com (kolotilov256)]]></author>
			<pubDate>Fri, 06 Mar 2020 22:55:51 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=138371#p138371</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=138366#p138366</link>
			<description><![CDATA[<p>Так это неправильно.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 06 Mar 2020 15:34:15 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=138366#p138366</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=138365#p138365</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />Ну такие тонкости в реальной работе с массивом никак не помешают. <br />Тем не менее <br /></p><div class="codebox"><pre><code>if (a[2] == b[2])
	msgbox true
else msgbox false</code></pre></div><p>выдает true, значит в ходе какого-нибудь процесса моя функция не должна поломать алгоритм.</p>]]></description>
			<author><![CDATA[null@example.com (kolotilov256)]]></author>
			<pubDate>Fri, 06 Mar 2020 15:31:22 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=138365#p138365</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=138347#p138347</link>
			<description><![CDATA[<p>Тоже не совсем:<br /></p><div class="codebox"><pre><code>a := [1]
a[3] := 3
b := [1, &quot;&quot;, 3]
MsgBox, % equal(a, b)
MsgBox, % a.HasKey(2) &quot;`n&quot; b.HasKey(2)

equal(Array1,Array2) 
{
   if !isObject(Array1) 
   {
      if (Array1 == Array2)
         return true
      else return false
   }
   else
   {
      leng1 := Array1.Length()
      leng2 := Array2.Length()
      if (leng1 = leng2) 
      {
         Loop % leng1 
            if !equal(Array1[A_Index], Array2[A_Index])
               return false
         return true
      }
      else return false
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 05 Mar 2020 20:59:20 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=138347#p138347</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=138346#p138346</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, да, не учёл частные случаи)<br />Теперь кажись нормально.</p><div class="codebox"><pre><code>equal(Array1,Array2) 
{
   if !isObject(Array1) 
   {
      if (Array1 == Array2)
         return true
      else return false
   }
   else
   {
      leng1 := Array1.Length()
      leng2 := Array2.Length()
      if (leng1 = leng2) 
      {
         Loop % leng1 
            if !equal(Array1[A_Index], Array2[A_Index])
               return false
         return true
      }
      else return false
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (kolotilov256)]]></author>
			<pubDate>Thu, 05 Mar 2020 20:36:52 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=138346#p138346</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=138332#p138332</link>
			<description><![CDATA[<p><strong>kolotilov256</strong><br />Ваша не работает:<br /></p><div class="codebox"><pre><code>a := [[]]
b := [[]]
MsgBox, % equal(a, b)

equal(Array1,Array2) {
   if !Array1[1] and !Array2[1] {
      if (Array1 = Array2)
         return true
      else return false
   } else {
      leng1 := Array1.Length()
      leng2 := Array2.Length()
      if (leng1 = leng2) {
         Loop % leng1 {
            if !equal(Array1[A_Index], Array2[A_Index])
               return false
         } return true
      } else return false
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 05 Mar 2020 15:20:19 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=138332#p138332</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=138330#p138330</link>
			<description><![CDATA[<p>Хэш суммы это конечно хорошо, но старый дедовский метод работает в 5 раз быстрее (Проверял через A_TickCount)</p><div class="codebox"><pre><code>equal(Array1,Array2) {
   if !Array1[1] and !Array2[1] {
      if (Array1 = Array2)
         return true
      else return false
   } else {
      leng1 := Array1.Length()
      leng2 := Array2.Length()
      if (leng1 = leng2) {
         Loop % leng1 {
            if !equal(Array1[A_Index], Array2[A_Index])
               return false
         } return true
      } else return false
   }
}</code></pre></div><p>Также держите ещё бонусом функцию find(Array, Var) для поиска элемента Var в массиве Array (Var тоже может быть массивом)<br /></p><div class="codebox"><pre><code>find(Array,Var) {
	For i, val in Array
		if equal(val,Var) or find(val,Var)
			return true
		
    return false
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (kolotilov256)]]></author>
			<pubDate>Thu, 05 Mar 2020 14:42:18 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=138330#p138330</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121219#p121219</link>
			<description><![CDATA[<div class="codebox"><pre><code>a := [&quot;123&quot;, &quot;123&quot;, &quot;123&quot;, &quot;222&quot;]
b := [&quot;123&quot;, &quot;123&quot;, &quot;123&quot;, &quot;222&quot;]

MsgBox % ArrayCompare(a, b)

ArrayCompare(obj1, obj2) {
	Loop 2
		VarSetCapacity(Bin%A_Index%, Size%A_Index% := RawObjectSize(obj%A_Index%, 0) + 8, 0)
		, RawObject(obj%A_Index%, NumPut(Size%A_Index% - 8, &amp;Bin%A_Index%, &quot;Int64&quot;), 0)
	If (Size1 != Size2)
		Return 0
	Return !DllCall(&quot;msvcrt\memcmp&quot;, Ptr, &amp;Bin1, Ptr, &amp;Bin2, Ptr, Size1)
	  ;	Return Size1 = DllCall(&quot;NtDll\RtlCompareMemory&quot;, Ptr, &amp;Bin1, Ptr, &amp;Bin2, Ptr, Size1, Ptr)
}

RawObject(obj, addr, buf := 0, objects := 0) {
	; Type.Enum:    Char.1 UChar.2 Short.3 UShort.4 Int.5 UInt.6 Int64.7 UInt64.8 Double.9 String.10 Object.11
	; Negative for keys and positive for values
	If !objects
		objects:={(&quot;&quot;):0,(obj):0}
	Else
		objects[obj]:=(++objects[&quot;&quot;])
	for k, v in obj
	{ ; 9 = Int64 for size and Char for type
		If IsObject(k) {
			If objects.HasKey(k)
				NumPut(-12,addr+0,&quot;Char&quot;),NumPut(objects[k],addr+1,&quot;Int64&quot;),addr+=9
			Else
				NumPut(-11,addr+0,&quot;Char&quot;),NumPut(sz:=RawObjectSize(k,buf),addr+1,&quot;Int64&quot;),RawObject(k,addr+9,buf,objects),addr+=sz+9
		} Else
			NumPut(-10,addr+0,&quot;Char&quot;),NumPut(sz:=StrPut(k,addr+9)*2,addr+1,&quot;Int64&quot;),addr+=sz+9
		If IsObject(v) {
			If objects.HasKey(v)
				NumPut(12,addr+0,&quot;Char&quot;),NumPut(objects[v],addr+1,&quot;Int64&quot;),addr+=9
			Else
				NumPut(11,addr+0,&quot;Char&quot;),NumPut(sz:=RawObjectSize(v,buf),addr+1,&quot;Int64&quot;),RawObject(v,addr+9,buf,objects),addr+=sz+9
		} Else
			NumPut(10,addr+0,&quot;Char&quot;),NumPut(sz:=buf?obj.GetCapacity(k):StrPut(v)*2,addr+1,&quot;Int64&quot;),DllCall(&quot;RtlMoveMemory&quot;,&quot;PTR&quot;,addr+9,&quot;PTR&quot;,buf?obj.GetAddress(k):&amp;v,&quot;PTR&quot;,sz),addr+=sz+9
	}
}

RawObjectSize(obj,buf:=0,objects:=0){
	If !objects
		objects:={(obj):1}
	Else If !objects.HasKey(obj)
		objects[obj]:=1
	for k, v in obj
	{
		If IsObject(k)
			sz+=objects.HasKey(k)?9:RawObjectSize(k,buf,objects)+9
		Else
			sz+=StrPut(k)*2+9
		If IsObject(v)
			sz+=objects.HasKey(v)?9:RawObjectSize(v,buf,objects)+9
		Else
			sz+=(buf?obj.GetCapacity(k):StrPut(v)*2)+9
	}
	Return sz
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 15 Nov 2017 14:30:38 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121219#p121219</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121202#p121202</link>
			<description><![CDATA[<p><a href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff561778%28v=vs.85%29.aspx?f=255&amp;MSPPError=-2147217396">Написано</a>, что доступна, начиная с Windows 2000.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 15 Nov 2017 01:04:51 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121202#p121202</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121199#p121199</link>
			<description><![CDATA[<p>А, понял, RtlCompareMemory может <a href="https://autohotkey.com/board/topic/4368-copy-compare-and-length-of-binary-variables/">не быть в XP</a>.</p>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Wed, 15 Nov 2017 00:49:11 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121199#p121199</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121195#p121195</link>
			<description><![CDATA[<p>Оба варианта вроде работают:<br /></p><div class="codebox"><pre><code>VarSetCapacity(var1, 4, 0)
VarSetCapacity(var2, 4, 0)

VarSetCapacity(var3, 4, 0)
VarSetCapacity(var4, 4, 0)

Loop 4  {
   i := A_Index
   Loop 4
      NumPut( (i = 4 &amp;&amp; A_Index = 4) ? 2 : 1, var%i%, A_Index - 1, &quot;UChar&quot;)  ; четвёртый буфер отличается
}

MsgBox, % DllCall(&quot;NtDll\RtlCompareMemory&quot;, Ptr, &amp;var1, Ptr, &amp;var2, Ptr, 4, Ptr)
MsgBox, % DllCall(&quot;NtDll\RtlCompareMemory&quot;, Ptr, &amp;var3, Ptr, &amp;var4, Ptr, 4, Ptr)

MsgBox, % DllCall(&quot;msvcrt\memcmp&quot;, Ptr, &amp;var1, Ptr, &amp;var2, Ptr, 4)
MsgBox, % DllCall(&quot;msvcrt\memcmp&quot;, Ptr, &amp;var3, Ptr, &amp;var4, Ptr, 4)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 14 Nov 2017 23:46:33 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121195#p121195</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121194#p121194</link>
			<description><![CDATA[<p><a href="https://autohotkey.com/boards/viewtopic.php?p=9976&amp;sid=f2e85250e91800a4f420af94fc48dac5#p9976">https://autohotkey.com/boards/viewtopic … dac5#p9976</a><br /></p><div class="codebox"><pre><code>MsgBox % FileCompare(&quot;D:\Image_004.png&quot;
	, &quot;D:\11.gif&quot;)
;Pass a relative or absolute filename for each file1 and file2
;Returns true if the contents of file1 = file2, or false if there are differences
FileCompare(file1, file2)
{
  FileGetSize, sFile1, %file1%
  FileGetSize, sFile2, %file2%
  if (sFile1 != sFile2)
    return 0  ;Not the same size so impossible to have the same contents
  FileRead, bFile1, *c %file1%
  FileRead, bFile2, *c %file2%
  return sFile1 = DllCall(&quot;ntdll\RtlCompareMemory&quot;, &quot;ptr&quot;, &amp;bFile1, &quot;ptr&quot;, &amp;bFile2, &quot;ptr&quot;, sFile1)
}</code></pre></div><p>Интересно, что Lazlo использовал в своем коде RtlFillMemory, RtlMoveMemory, а для сравнения задействовал memcmp из библиотеки msvcrt.</p>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Tue, 14 Nov 2017 23:37:47 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121194#p121194</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121186#p121186</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>Все же интересно, для ресурсов в памяти должен ведь быть способ побитовой сверки?</p></blockquote></div><p>Winapi-функции вроде нет.</p></blockquote></div><p>RtlCompareMemory?<br /><a href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff561778(v=vs.85).aspx">https://msdn.microsoft.com/en-us/librar … s.85).aspx</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Tue, 14 Nov 2017 21:58:16 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121186#p121186</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Сравнение массива с массивом]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121182#p121182</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Есть у кого мысли по поводу предыдущего поста, не нашёл в справке про то что бинарные данные можно сравнивать.</p></blockquote></div><p> Мож это?<br /></p><div class="quotebox"><cite>AutoHotkey(RUS).chm пишет:</cite><blockquote><p><strong>Переменные и выражения</strong><br />...<br /><strong>^</strong> Побитовое исключающиее ИЛИ (^)</p></blockquote></div><p>Если в результате этого действия получаем ноль, значит строки одинаковые.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Tue, 14 Nov 2017 20:34:13 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121182#p121182</guid>
		</item>
	</channel>
</rss>
