3

I want an associative array in d programming language. The key is a struct with two shorts. Easy so far.

struct kie { short a; short b; }
short[kie] possibles;

Problem is I want to hold more than value per key. Dynamic would be useful so it can grow and shrink per key When I try to allocate a dynamic array as value to a to key i.e

short[] temp; ... possibles[k] = temp;

I get the understandable error su.d(30): Error: cannot append type short[] to type short

How do I declare an associative array where the values can be a dynamic array of numbers?

4

1 回答 1

3

通常是将 type的值Value[Key]映射到 type 的值的关联数组。如果你想要一个 to 的地图,那么你需要准确地声明:KeyValuekieshort[]

short[][kie]

这应该够了吧。

于 2013-10-20T15:23:27.777 回答