remove lines present in both long sorted lists

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
adrianh
Posts: 135
Joined: 28 Jul 2014, 15:34

Re: remove lines present in both long sorted lists

Post by adrianh » 05 Dec 2022, 11:39

mikeyww wrote:
04 Dec 2022, 08:16
Is yours doing a union? I think it's supposed to be removing the duplicates.

This revision does seem to get the elapsed time down to approximately zero seconds.

Code: Select all

SetBatchLines -1
dir    = %A_ScriptDir%
out   := FileOpen(dir "\result.txt", "w `n")
line  := {}
start := A_TickCount
Loop, Read, %dir%\LISTA.txt
 line[A_LoopReadLine] := True
Loop, Read, %dir%\LISTB.txt
 (!line.HasKey(A_LoopReadLine)) && out.WriteLine(A_LoopReadLine)
out := ""
MsgBox, 64, Elapsed time, % A_TickCount - start " ms"

image221204-0837-001.png
Nice. Using the object's key as a set was my first thought.

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: remove lines present in both long sorted lists

Post by mikeyww » 05 Dec 2022, 11:47

Good. Smile_'s idea. Generalized: viewtopic.php?p=494531#p494531

Post Reply

Return to “Ask for Help (v1)”