Using sets in associative arrays
Ralph
ralph at mail.com
Tue Nov 12 09:18:25 UTC 2024
On Tuesday, 12 November 2024 at 07:47:58 UTC, Sergey wrote:
> On Tuesday, 12 November 2024 at 00:42:41 UTC, Ralph wrote:
>> 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?
Thank you both for your help!
More information about the Digitalmars-d-learn
mailing list