wish: Multi-dimension List collection

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
In a program I'm converting, I have arrays like All(5,5,5,13) and as far as I can tell, there is no easy way to put that into a List, unless I'm missing something. It's not that I'm any worse off than in VB, but it would be nice to be able to convert the array to a List because of all the advantages a List has.
 

Dextrosoft

Member
Licensed User
Longtime User
HI,
How about using a list in a list ?

As a list can store any object, it can store another list or map.

For ease use, you could create some wrapper subs.
ie
Someting like this :

Sub GetMultiArray(FIrstindex as long, SecondIndex as long ) as whatever



Cheers;
Wim
 

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
Unless I'm missing something, breaking an array(5,5,5,13) into separate 1-dimension Lists is going to require a LOT of Lists, each of which must be addressed separately. If so, I'm better off staying with the array(5,5,5,13) and doing without List's advantages (such as .Size, .Sort, .Get, etc.)
 

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
Does assigning a Type to a List allow me to do anything that I can't do by assigning an array to a List?

My program has an array PossibleCardHoldings(player1, player2, suit, card)
where player1 = 0-3, player2 = 0-03, suit = 0-3, and card = 0-12
which allows me to look from player1's perspective to see if player2 may have, say, the ace (12) of clubs (3), which would be
If PossibleCardHoldings(p1, p2, 3, 12) = True...
To keep track of how many clubs player2 may have requires a second array:
PossibleNumberOfCards(player1, player2, suit)

If a multi-dimension List were possible, to check the card holding would be
If PossibleCardHoldings(p1, p2, 3).IndexOf(12) > -1
and the number of clubs player 2 may have would be
PossibleCardHoldings(p1, p2, 3).Size
so there is only one List to update for both functions.

There are other advantages to using a List. This is just one example.
 

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
A Type can have different types of values and is also easier to work with in some cases.

I understand that, but in the example I gave, all the values are integers. I showed what I need to be able to do. Can I do that by putting a defined Type into a List?

Would it be that hard to make a List multi-dimensional?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Can I do that by putting a defined Type into a List?
You will still need to implement a loop that goes over the values and check for a match.

Would it be that hard to make a List multi-dimensional?
There is no such List in Java libraries. It is possible to implement one but it will be a pretty difficult task.
 
Top