Using sets in associative arrays

Ralph ralph at mail.com
Tue Nov 12 00:42:41 UTC 2024


Hi there,

I know it is possible to declare an associative array which takes 
arrays as values, i.e.
**int[][int] arr;**
A sample of this could be
**arr[2] = [2, 3, 2, 4, 5];**

I was wondering if there was a way to have this with sets instead 
of arrays. In D, sets are equivalent to red-black trees, afaik. 
Almost as expected, the declaration
**redBlackTree[int] arr;**
such that (according to the initial example) **arr[2]** would be 
[2, 3, 4, 5]
does not work.

Would anybody know of a workaround?


More information about the Digitalmars-d-learn mailing list