Thanks Adam.

Couple of follow up questions, if you don't mind:

On Sunday, 21 August 2016 at 23:37:38 UTC, Adam D. Ruppe wrote:
testStruct[int] testStructArray;
That's not actually an array per se, that is a key/value map where the keys are ints.
I understand it's a map, but does my syntax not define an Associative Array?? https://dlang.org/spec/hash-map.html That's kinda what I wanted because I want to be able to look up the Structs by the value of int.

Either do a traditional array and copy struct values onto it or do an array of pointers and new them. Which option is bsed depends on the details of what you're doing.

This was a simple example of what I wanted to illustrate the problem. What I probably want for my future program state is some sort of hash map, as I'll be using this "array" as a lookup table.
So conceptually something like:

userid | username | structs
----------------------------
0001   | brian    | structAboutBrian
0002   | john     | structAboutJohn

I probably want to be able to look up info using either userid, or username, but I can settle for one of them I'm creating the entries during execution of the program, so I have no idea how big the structure is going to be. So I wanted something dynamic.

I'm a bit of a novice in terms of theoretical comp sci, so I'm not sure what data structure would be best suited to something like that, or how to implement. Happy to take advice. :)

Reply via email to