BuluBulu27

Multimap in Autoit?

22 posts in this topic

Hello!

I would like to get every triplets (X,Y,Z) for a triplet (A,B,C).

Example: Multimap(A,B,C) would return a List containing (X1,Y1,Z1), ..., (Xn,Yn,Zn)

It seems that a multimap would be the way to do it, but I can't seem to find anything on that matter in AutoIt.
Does anyone have an efficient implementation of a multimap or something that gets the job done?

Thank you.

Share this post


Link to post
Share on other sites



BuluBulu27,

Welcome to the AutoIt forums.

_ArrayPermute would seem to be what you need:

#include <Array.au3>

Global $aArray[] = ["A", "B", "C"]

$aPerm = _ArrayPermute($aArray)

_ArrayDisplay($aPerm, "", Default, 8)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Melba23,

Thank you for your help.

_ArrayPermute gives me every combination of (A,B,C) so for a triplet, I would get 6 combinations every time.

However, it's not exactly what I'm looking for.
A practical example of what I'm trying to achieve would be:
Multimap.add( (A,B,C) , (X1,Y1,Z1) )
Multimap.add( (A,B,C) , (X2,Y2,Z2) )
And then Multimap(A,B,C) would return me (X1,Y1,Z1) and (X2,Y2,Z2)

BuluBulu27
 

Share this post


Link to post
Share on other sites

BuluBulu27,

Could you please explain why you need to do this? If we understand the end result you are seeking we might be able to offer some focused suggestions as to how to get there.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Nested arrays are close to what you expect but their use isn't recommended nor practical.

A good alternative would be to use a 2D array.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Melba23,

I'm trying to store the position and status of a certain object in a 2D world.

I am moving in a 2D world, looking for a type of object. So my A,B,C would be posX, posY and objectType.
I would like to store the position on the screen of the object, and its color. So my X,Y,Z would be cursorX, cursorY and color.

BuluBulu27

Share this post


Link to post
Share on other sites

jchd,

A 2D array would get the job done but I would have to navigate through it every time, which would be extremely slow, considering I have 6 arguments.

At most it would be O(n^6).

Is there no faster way?

Share this post


Link to post
Share on other sites

Ha, for a game, again. So no.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

BuluBulu27,

Is this a game you are writing in AutoIt or a third-party app? As you can see from the Forum rules we are happy to support the former but not the latter.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#10 ·  Posted

No, not for a game. This was a simplified explanation for Melba to understand the situation.

A state machine gives me a certain GUI with a mapID, a sessionID, and an objectID. I want to count every occurrence, store their position and state, and compare it between multiple sessions.

Share this post


Link to post
Share on other sites

#11 ·  Posted

The state machine is part of a school project I've made this year, and I'm merely trying to learn to handle different situations in AutoIt.

So, can you help me?

Share this post


Link to post
Share on other sites

#12 ·  Posted

BuluBulu27,

From what little you have described of your requirements, I agree with jchd's assessment that nested arrays might be the nearest solution - but I also agree with his comment about their practicality.

Can you give us some real-world examples of the sort of data you need to store and subsequently recover? Personally I am still having some difficulty understanding exactly what it is you are trying to do.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#13 ·  Posted

Melba23,

I see, I was hoping for a more effective solution, such as an AutoIt equivalent of Java's Multimap.

We can even change the situation and simplify the problem.
Given a country and a date, I would like to get the name and temperature of every town previously stored for this date and country.

I don't really see how to simplify it more than by saying "I need to get every tuple previously stored for a certain tuple".
Considering I'm just trying to improve my coding, the exact situation doesn't really matter.

BuluBulu27

Share this post


Link to post
Share on other sites

#14 ·  Posted

BuluBulu27,

That sounds like a job for a database. AutoIt has a SQLite UDF which should allow you to store and access that sort of data very easily - and jchd is an acknowledged guru in that field.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#15 ·  Posted

Melba23,

Thank you, I was afraid SQL would be even slower than 2D arrays.

jchd,

Considering you're the guru of SQL, would using a SQLite UDF be faster than iterating over a 2D array?

BuluBulu27

Share this post


Link to post
Share on other sites

#16 ·  Posted

It all depends of the situation. A table for storing 5 tuples of 6 simple values each is certainly overkill but if you really have to store significantly more, a memory- or disk-based SQLite DB would be nice to work with.

AutoIt doesn't have a tuple (or list or whatever you name it) variant but a row in an SQL table is very close to that. The bonus is that you can enjoy the power of SQL to efficiently insert, update and select rows on non-trivial criterion and order the resultset on other non-trivial criterion, something that would otherwise require painful ad-hoc applicative code for every request.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#17 ·  Posted

As of right now, I'd only be dealing with, at most, a thousand rows.

Would the user notice any downtime or is the SQL environment correctly implemented into AutoIt?

Share this post


Link to post
Share on other sites

#18 ·  Posted

Don't expect anything noticeable to human eyes, either solution. Use array(s) if it's simple, codewise, for you to navigate inside, use SQL if you may have to manage and/or order tuples over non-trivial conditions.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#19 ·  Posted

Alright, will do.
Thanks to you both for your time.

Share this post


Link to post
Share on other sites

#20 ·  Posted

Try what you think is more adequate and if you experience issues with SQLite just ask.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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