Thread overview
Collections in D
Jan 13, 2021
Roguish
Jan 13, 2021
Ferhat Kurtulmuş
Jan 13, 2021
Roguish
Jan 13, 2021
evilrat
Jan 13, 2021
Roguish
Jan 13, 2021
Ferhat Kurtulmuş
Jan 13, 2021
Roguish
Jan 13, 2021
mw
January 13, 2021
I can't find anything about collections in D. All I have found are arrays and maps ("associative arrays"). What about lists and sets? What if I just want a linked list?
January 13, 2021
On Wednesday, 13 January 2021 at 11:58:11 UTC, Roguish wrote:
> I can't find anything about collections in D. All I have found are arrays and maps ("associative arrays"). What about lists and sets? What if I just want a linked list?

You can refer to the docs for them:

https://dlang.org/phobos/std_container.html

https://dlang.org/phobos/std_container_slist.html
https://dlang.org/phobos/std_container_dlist.html

For sets see:
https://forum.dlang.org/thread/vqyxqkcszqfwpgqtjgcm@forum.dlang.org

January 13, 2021
On Wednesday, 13 January 2021 at 11:58:11 UTC, Roguish wrote:
> I can't find anything about collections in D. All I have found are arrays and maps ("associative arrays"). What about lists and sets? What if I just want a linked list?

It seems collections are called "containers" in D's standard library, which explains why I didn't find anything searching for "collections".

As concerns linked lists, I have found

   https://dlang.org/phobos/std_container_dlist.html

which seems perfectly adequate.

What about sets?
January 13, 2021
On Wednesday, 13 January 2021 at 12:06:05 UTC, Roguish wrote:
>
> What about sets?

There is no specific set container, they just implemented as generic algorithms over the ranges.

There is a section for set operations (std.algorithm.setops module).
https://dlang.org/phobos/std_algorithm.html
January 13, 2021
On Wednesday, 13 January 2021 at 12:06:05 UTC, Roguish wrote:
> On Wednesday, 13 January 2021 at 11:58:11 UTC, Roguish wrote:
>> I can't find anything about collections in D. All I have found are arrays and maps ("associative arrays"). What about lists and sets? What if I just want a linked list?
>
> It seems collections are called "containers" in D's standard library, which explains why I didn't find anything searching for "collections".
>
> As concerns linked lists, I have found
>
>    https://dlang.org/phobos/std_container_dlist.html
>
> which seems perfectly adequate.
>
> What about sets?

I read many posts that rbtree can be a replacement for sets in dlang.

see its behaviour is identical.

https://dlang.org/phobos/std_container_rbtree.html
January 13, 2021
On Wednesday, 13 January 2021 at 12:48:47 UTC, Ferhat Kurtulmuş wrote:
> I read many posts that rbtree can be a replacement for sets in dlang.
>
> see its behaviour is identical.

Thanks, will read up.


January 13, 2021
On Wednesday, 13 January 2021 at 12:39:50 UTC, evilrat wrote:
> There is no specific set container, they just implemented as generic algorithms over the ranges.

I see. Thanks for pointing that out.

January 13, 2021
On Wednesday, 13 January 2021 at 12:06:05 UTC, Roguish wrote:

>
> which seems perfectly adequate.
>
> What about sets?

You can also search https://code.dlang.org

I use:

https://code.dlang.org/packages/emsi_containers

Which has hashset:

https://github.com/dlang-community/containers/blob/fc1625a5a0c253272b80addfb4107928495fd647/src/containers/hashset.d