In most languages there is some sort of List<T>
type, is that the same for D?
Thread overview | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 10, 2022 Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
December 10, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to thebluepandabear | On 12/10/22 12:46 AM, thebluepandabear wrote: >In most languages there is some sort of D doesn't focus on interfaces, we have concepts, like ranges. Sorry, it's hard to answer your question without asking more questions: are you looking for a linked list? A list API? A specific list interface? -Steve |
December 10, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Saturday, 10 December 2022 at 05:54:09 UTC, Steven Schveighoffer wrote: >On 12/10/22 12:46 AM, thebluepandabear wrote: >In most languages there is some sort of D doesn't focus on interfaces, we have concepts, like ranges. Sorry, it's hard to answer your question without asking more questions: are you looking for a linked list? A list API? A specific list interface? -Steve I was wondering more if there is an object oriented way of creating arrays, like in Java there is an |
December 10, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to thebluepandabear | On 12/10/22 1:11 AM, thebluepandabear wrote: >I was wondering more if there is an object oriented way of creating arrays, like in Java there is an In D, you just use -Steve |
December 10, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to thebluepandabear | On 12/9/22 22:11, thebluepandabear wrote: > I was wondering more if there is an object oriented way of creating > arrays, Every collection has its own special interface. Object orientation don't go well with collections. For example, you wouldn't want indexing operator for a linked list. > like in Java there is an `ArrayList`, in C++ there is > `std::vector`, etc. They are all dynamic arrays behind the scenes. Arrays are so much better than linked lists that linked lists don't have much use outside of interviews. - Arrays use less memory - Provide constant time element access - Amortized constant time element addition - Constant time element removal in some cases (move the last element in place of the removed one) - Ability to sort to find elements in logN time later on - Arrays get special help from the CPU (e.g. cache prefetches) There isn't a single point in favor of linked lists. Ali |
December 10, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to thebluepandabear | On Saturday, 10 December 2022 at 05:46:26 UTC, thebluepandabear wrote: >In most languages there is some sort of The standard library has many possibilities, including linked lists. What about the news from the range... In D, the concept of range is very advanced. Now I'm going to show you 3 examples and two of them are from the standard library and the other is a nice wrap:
SDB@79 |
December 11, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Salih Dincer | On Saturday, 10 December 2022 at 19:49:23 UTC, Salih Dincer wrote: >SDB@79 Can the |
December 11, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to zjh | On Sunday, 11 December 2022 at 03:13:17 UTC, zjh wrote: >On Saturday, 10 December 2022 at 19:49:23 UTC, Salih Dincer wrote: >SDB@79 Can the Certainly, there are many ways to do this. For example:
SDB@79 |
December 11, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Salih Dincer | On Sunday, 11 December 2022 at 07:47:35 UTC, Salih Dincer wrote: >.. Thank you for your reply. I think if you take |
December 11, 2022 Re: Is there such concept of a list in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to thebluepandabear | On Saturday, 10 December 2022 at 05:46:26 UTC, thebluepandabear wrote: >In most languages there is some sort of There is: https://dlang.org/phobos/std_container_dlist.html Why is it called |