five35
New member
I need to create a collection which I can iterate over in a specific order as well as test for inclusion. Because maps always sort by key and can't be tested for value inclusion (that I know of; I'm very new to ASH scripting), I haven't been able to implement this as a single data structure. Instead, I'm currently using two; one for iteration order and another for inclusion testing (see below). Is there a way around this?
Code:
string[3] MY_DATA_ORDERED;
MY_DATA_ORDERED[0] = "First";
MY_DATA_ORDERED[1] = "Second";
MY_DATA_ORDERED[2] = "Third";
boolean[string] MY_DATA;
foreach index in MY_DATA_ORDERED MY_DATA[MY_DATA_ORDERED[index]] = true;
// Now I can iterate in order:
foreach index in MY_DATA_ORDERED print(MY_DATA_ORDERED[index]);
// Or test for inclusion:
if (MY_DATA contains "Second") print("All is well.");
if (MY_DATA contains "Fourth") print("Something screwy is going on!");
Last edited: