Jump to content
Biatu

2D System.Collections.ArrayList?

Recommended Posts

Biatu

Hello, does anyone know if it is possible to create a 2D ArrayList?, i'm trying to compare 2 2D arrays.

 

Thank you

 

Edit:
I would use a basic compare but, im dealing with arrays that have >200,000 entries.

Edited by Biatu

What is what? What is what.

Share this post


Link to post
Share on other sites
kylomas

@junkew - Can you expand on your answer.  I do not understand how it fits the question.

Thanks,

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
iamtheky

@kylomas

As Melba points out one post later, our OP should just use a map since those are a thing now.  But this is how the objcreate recommendation ties in:  

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
LarsJ

Share this post


Link to post
Share on other sites
iamtheky

Not ideal surely, but with delimiters and arrays of arrays you could RubeGoldberg a solution.

#include <File.au3>


$VALUE = ""
$tmp = "testlist.txt"
filedelete($tmp)

$ObjList = ObjCreate("System.Collections.ArrayList")

_AddToList($ObjList , "row0col0|row0col1|row0col2")
_AddToList($ObjList , "row1col0|row1col1")
_AddToList($ObjList , "row2col0|row2col1|row2col2|row2col3")

_ArrayDisplay(_ShowList())

Func _AddToList($Obj , $Str)
    $Index = $Obj.Add($Str)
    $VALUE &= $ObjList.Item($Index) & @CR
EndFunc

Func _ShowList()
    local $aTmp
    local $aCols[0]

    filewrite($tmp , stringtrimright($VALUE , 1))
    _FileReadToArray($tmp , $aTmp , 2 , "|")

        For $i = 0 to ubound($aTmp) - 1
            _ArrayAdd($aCols , ubound($aTmp[$i]))
            _ArrayTranspose($aTmp[$i])
        Next

        local $aFINAL[0][_ArrayMax($aCols)]

        For $i = 0 to ubound($aTmp) - 1
            _ArrayAdd($aFINAL , $aTmp[$i])
        Next

return $aFINAL

EndFunc

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
LarsJ

How fast is this code? It doesn't look very fast.

And how will you continue to compare the two arrays? Will you make two arraylists, sort them and then compare the sorted arrays. It'll take forever.

Or will you only create one arraylist, sort it and do a binary search in the arraylist for all of the rows in the other array. It'll also take a long time.


Biatu, A 2D ArrayList does not exist. And an ArrayList is not useful for comparing two 2D arrays.

What exactly do you mean by comparing two 2D arrays? And what result do you expect? Do you want information about each and every difference in the two arrays?

Are the two arrays sorted or are they not sorted? If they are not sorted in advance, an initial sorting is in many cases not worth it.

What do you mean by 200,000 entries? Do you mean 200,000 rows and maybe 10 columns so we are talking about 2,000,000 elements? Or do you mean 200,000 elements eg. 20,000 rows and 10 columns. In the last case, pure AutoIt code is sufficient. In the first case, some optimized code will be fastest.

If you want more help beyond the question of ArrayLists, you'll have to give us some more information.

Share this post


Link to post
Share on other sites
iamtheky

how fast is that wall of text, it doesnt look to actually do anything at all?


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
kylomas

If the OP is looking for all of A in B, all of B in A (or then NOT of this) then a DB solution seems best for working with sets (arrays).  As some of you have said, we need more INFO!


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
iamtheky

Having one really good hammer is fine. But why not create many mediocre hammers when given the opportunity?  When was the last time you spent 20 minutes flexing arraylist to see what was possible?  You want to correct the request to suit your answer, instead of enjoying the request.

It's like playing with handcuffs on.

Also, if the only issue you find is speed, then there are probably new pieces that have other more reasonable applications and should not necessarily be discarded.

edit:  GD win10 edge made new post instead of edit again, sorry, IPB needs to fix that UI.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
LarsJ

iamtheky, Create two 2D arrays with 20,000 rows, 10 columns, 100 differences. The details are up to you. And let's simply test different solutions.

Share this post


Link to post
Share on other sites
Biatu
On 11/6/2017 at 1:46 PM, LarsJ said:

How fast is this code? It doesn't look very fast.

And how will you continue to compare the two arrays? Will you make two arraylists, sort them and then compare the sorted arrays. It'll take forever.

Or will you only create one arraylist, sort it and do a binary search in the arraylist for all of the rows in the other array. It'll also take a long time.


Biatu, A 2D ArrayList does not exist. And an ArrayList is not useful for comparing two 2D arrays.

What exactly do you mean by comparing two 2D arrays? And what result do you expect? Do you want information about each and every difference in the two arrays?

Are the two arrays sorted or are they not sorted? If they are not sorted in advance, an initial sorting is in many cases not worth it.

What do you mean by 200,000 entries? Do you mean 200,000 rows and maybe 10 columns so we are talking about 2,000,000 elements? Or do you mean 200,000 elements eg. 20,000 rows and 10 columns. In the last case, pure AutoIt code is sufficient. In the first case, some optimized code will be fastest.

If you want more help beyond the question of ArrayLists, you'll have to give us some more information.

It is to compare the differences between 2 large arrays containing files or registry info.

$aFiles[1+n][0]=$sPath
$aFiles[1+n][1]=$sSHA1

$aReg[1+n][0]=$sPath
$aReg[1+n][1]=$sType
$aReg[1+n][2]=$sVal


$aFiles will be loaded from a delimited ini, containing the last state, then compared with a fresh scan. My Current solution for $aFiles is to extract only [n][0] from both array and compare.

With $aReg, I need to check for new/missing keys, and changed values/types.
Up top it was mentioned to use a delimited string for each row, then split the resulting array and process accordingly. <- seems to be the resolution

Edited by Biatu

What is what? What is what.

Share this post


Link to post
Share on other sites
LarsJ

We need test data (100 rows) and we need to see code that produces the results you want, with the test data as input. It's no hurry. You can take the time you need.

A few years ago, there was a question of making a script faster. This thread shows how pure AutoIt code can be optimized. Here two years later we can take code optimization a few steps further.

First, we can use compiled code. Secondly, we can use multithreaded code.

With the examples Accessing AutoIt Variables, Using C# and VB Code and .NET Common Language Runtime (CLR) Framework we can transfer an AutoIt array directly to compiled code as a function parameter, thus manipulating arrays directly in compiled code, eg. VB code.

And as the example in Using C# and VB Code post 8 shows, it's not too hard to perform array calculations with multiple threads, if the array can be divided into smaller parts that can be calculated in each thread.

It's especially because of the last achievements that I am interested in this problem. I'm interested in testing the techniques on some real examples.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.