Ascer Posted February 17, 2018 Posted February 17, 2018 (edited) 1. Description. Udf working with MSDN System.Collections.ArrayList. Allow you to make fast operations on huge arrays, speed is even x10 better than basic _ArrayAdd. Not prefered for small arrays < 600 items. 2. Requirements .NET Framework 1.1 - 4.5 (on this version Microsoft destroy old rules) System Windows 3. Possibilities. ;=============================================================================================================== ; UDF Name: List.au3 ; ; Date: 2018-02-17, 10:52 ; Description: Simple udf to create System Collections as ArrayList and make multiple actions on them. ; ; Function(s): _ListCreate -> Creates a new list ; _ListCapacity -> Gets a list size in bytes ; _ListCount -> Gets items count in list ; _ListIsFixedSize -> Get bool if list if fixed size ; _ListIsReadOnly -> Get bool if list is read only ; _ListIsSynchronized -> Get bool if list is synchronized ; _ListGetItem -> Get item on index ; _ListSetItem -> Set item on index ; ; _ListAdd -> Add item at end of list ; _ListClear -> Remove all list items ; _ListClone -> Duplicate list in new var ; _ListContains -> Get bool if item is in list ; _ListGetHashCode -> Get hash code for list ; _ListGetRange -> Get list with items between indexs ; _ListIndexOf -> Get index of item ; _ListInsert -> Insert a new item on index ; _ListInsertRange -> Insert list into list on index ; _ListLastIndexOf -> Get index last of item ; _ListRemove -> Remove first found item ; _ListRemoveAt -> Remove item in index ; _ListRemoveRange -> Remove items between indexs ; _ListReverse -> Reverse all items in list ; _ListSetRange -> Set new value for items in range ; _ListSort -> Sort items in list (speed of reading) ; _ListToString -> Get list object name ; _ListTrimToSize -> Remove unused space in list ; ; Author(s): Ascer ;=============================================================================================================== 4. Downloads List.au3 5. Examples SpeedTest _ArrayAdd vs ListAdd SpeedTest ArraySearch vs ListIndexOf Basic usage - crating guild with members Edited February 21, 2018 by Ascer junkew and Earthshine 2
Ascer Posted February 17, 2018 Author Posted February 17, 2018 (edited) SpeedTest ArrayAdd vs ListAdd #include <Array.au3> #include <List.au3> ;==> _ListAdd() Local $iItems = 5000 ConsoleWrite("[_ListAdd]" & @CRLF) ConsoleWrite("Start adding " & $iItems & " items using _ListAdd func..." & @CRLF) Local $aListAdd = _ListCreate() Local $iListAddTime = TimerInit() For $i = 1 To $iItems _ListAdd($aListAdd, $i) Next ConsoleWrite("Adding has end. Time spent on this action is " & Int(TimerDiff($iListAddTime)) & " ms." & @CRLF) ConsoleWrite("UBound of $aListAdd is " & _ListCount($aListAdd) & "." & @CRLF & @CRLF & @CRLF) ;==> _ArrayAdd() ConsoleWrite("[_ArrayAdd]" & @CRLF) ConsoleWrite("Start adding " & $iItems & " items using _ArrayAdd func..." & @CRLF) Dim $aArrayAdd[0] Local $iArrayAddTime = TimerInit() For $i = 1 To $iItems _ArrayAdd($aArrayAdd, $i) Next ConsoleWrite("Adding has end. Time spent on this action is " & Int(TimerDiff($iArrayAddTime)) & " ms." & @CRLF) ConsoleWrite("UBound of $aArrayAdd is " & UBound($aArrayAdd) & "." & @CRLF) Edited February 17, 2018 by Ascer
Ascer Posted February 17, 2018 Author Posted February 17, 2018 TestSpeed ArraySearch vs ListIndexOf expandcollapse popup#include <Array.au3> #include <List.au3> ConsoleWrite("Preparing array and list for later use..." & @CRLF) Local $iSearchItem = 4999 Dim $aArray[0] For $i = 0 To 5000 _ArrayAdd($aArray, $i) Next Local $aList = _ListCreate() For $i = 0 To 5000 _ListAdd($aList, $i) Next ConsoleWrite("$aArray and $aList are ready." & @CRLF & @CRLF) ConsoleWrite("Searching $aArray for item " & $iSearchItem & "..." & @CRLF) Local $iArrayTime = TimerInit() Local $iArrayFound = _ArraySearch($aArray, $iSearchItem) If $iArrayFound <> - 1 Then ConsoleWrite("Found item in " & TimerDiff($iArrayTime) & " ms." & @CRLF & @CRLF) EndIf ConsoleWrite("Searching $aList for item " & $iSearchItem & "..." & @CRLF) Local $iListTime = TimerInit() Local $vListFound = _ListIndexOf($aList, $iSearchItem) If $vListFound <> Null Then ConsoleWrite("Found item in " & TimerDiff($iListTime) & " ms." & @CRLF) EndIf
Ascer Posted February 17, 2018 Author Posted February 17, 2018 (edited) Basic usage - creating guild with members expandcollapse popup#include <List.au3> ConsoleWrite("Creating list for guild members..." & @CRLF) Local $aMembers = _ListCreate() Local $iTotalMembers = 1000 ConsoleWrite("Successfully created list." & @CRLF) ConsoleWrite("Creating guild members..." & @CRLF) For $i = 1 To $iTotalMembers Local $aMember = _CreateMember( _ "Member_" & $i, _ "Vocation_" & Random(1, 4, 1), _ Random(50, 250, 1), _ "Rank_" & Random(1, 3, 1) _ ) _ListAdd($aMembers, $aMember) Next ConsoleWrite("Successfully created " & $iTotalMembers & " members." & @CRLF) ConsoleWrite("Successfully added members to list." & @CRLF) ConsoleWrite("Preparing for display list..." & @CRLF) Local $sDisplay For $aMember In $aMembers $sDisplay &= "Browse Member..." & @CRLF $sDisplay &= @TAB & "Name = " & _ListGetItem($aMember, 0) & @CRLF $sDisplay &= @TAB & "Vocation = " & _ListGetItem($aMember, 1) & @CRLF $sDisplay &= @TAB & "Level = " & _ListGetItem($aMember, 2) & @CRLF $sDisplay &= @TAB & "Rank = " & _ListGetItem($aMember, 3) & @CRLF Next ConsoleWrite($sDisplay) Func _CreateMember($sName, $sVocation, $iLevel, $sRank) Local $aMember = _ListCreate() _ListAdd($aMember, $sName) _ListAdd($aMember, $sVocation) _ListAdd($aMember, $iLevel) _ListAdd($aMember, $sRank) Return $aMember EndFunc ;==>_CreateMember Edited February 17, 2018 by Ascer
junkew Posted February 18, 2018 Posted February 18, 2018 (edited) Speed example results on my system but would be interesting to see all native AutoIt and .NET collections compared (including maps in beta AutoIt)http://geekswithblogs.net/BlackRabbitCoder/archive/2011/06/16/c.net-fundamentals-choosing-the-right-collection-class.aspx SpeedTest _ArrayAdd vs ListAdd [_ListAdd] Start adding 5000 items using _ListAdd func... Adding has end. Time spent on this action is 103 ms. UBound of $aListAdd is 5000. [_ArrayAdd] Start adding 5000 items using _ArrayAdd func... Adding has end. Time spent on this action is 3424 ms. UBound of $aArrayAdd is 5000. TestSpeed ArraySearch vs ListIndexOf Preparing array and list for later use... $aArray and $aList are ready. Searching $aArray for item 4999... Found item in 3.74687017624091 ms. Searching $aList for item 4999... Found item in 0.311995511007418 ms. And this one some nice VB .NET steps to the arrays in post#2 Edited February 18, 2018 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
ptrex Posted February 21, 2018 Posted February 21, 2018 Don't want to be spoiling the fun. But calling calling .Net collection calling using conventional COM will be faded out. Usage of .NET Collections types in VBScript is not supported after .NET 4.5 Rgds, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Ascer Posted February 21, 2018 Author Posted February 21, 2018 @ptrex I've added note about this in requiments. Did you hear about OLEView.exe ? to check current available objects on your machine? On my Windows 7 x64 and Windows Server 2008 R2. ArrayList working good. What you tell about WIA.Vector ?
junkew Posted February 21, 2018 Posted February 21, 2018 (edited) This can be a workaround to do still nice tricks (or use CLR.AU3) https://sites.google.com/site/jozsefbekes/Home/windows-programming/dotnet-registering-an-object-to-the-running-object-table-from-a-non-com-project http://www.mvps.org/scripting/dotnet/ Edited February 21, 2018 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
ptrex Posted February 22, 2018 Posted February 22, 2018 Vector Object seems to be working fine on Win7 and 10 , Performance not tested ... local $v $v = ObjCreate("WIA.vector") $v.Add(1) $v.Add(42) $v.Add(3) $v.Remove(1) $v.Remove(2) ConsoleWrite("$v(1) = " & $v(1) & @CRLF) $v.Clear $v.Add("This") $v.Add("Is") $v.Add("Cool") $v.Remove(1) $v.Remove(1) ConsoleWrite("$v(1) = " & $v(1) & @CRLF) Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Earthshine Posted February 22, 2018 Posted February 22, 2018 (edited) C# is my pick. Nothing you can’t do. Lists can be covert to array and back instantly. Tons of methods to use for anything you want. Now there is a new type Span<T> that lets us do even more in .net Core 2.1 https://msdn.microsoft.com/en-us/magazine/mt814808.aspx Edited February 22, 2018 by Earthshine My resources are limited. You must ask the right questions
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now