3 ms·
I think it's a cultural thing rather than a technical one. I haven't used a linked list in 15+ years, because in C++ a std::vector is the 'default'. Before that
by roel_v 8y ago
I think it's a cultural thing rather than a technical one. I haven't used a linked list in 15+ years, because in C++ a std::vector is the 'default'. Before that, I wrote (some) C for Gnome, and the 'default' in Glib is a linked list. I don't know/remember if there is a reasonable, easy to use data structure that wraps a dynamically allocated array in Glib, but most of the 'sample' code at the time used the glib list. So that's what everybody kept on doing.
- pm215 8y agoI think GArray is the wrapper for a dynamically allocated array.
- roel_v 8y agoAh yes it is, thank you. I should have know about this 15 years ago :)
- blattimwind 8y agoI've seen LinkedList often used as the go-to list in Java, instead of ArrayList. They're also common in C, for example, a huge number of structures in the Linux kernel are linked lists.
- majewsky 8y ago> for example, a huge number of structures in the Linux kernel are linked lists. Which allocator is used for these? I'm not familiar with the Linux kernel, but since there is no malloc() in the kernel, I would guess that they allocate from an arena that's going to be page-aligned and thus exhibit the same locality characteristics as a vector.
- blattimwind 8y agoOh, they have malloc, it's just kalled kmalloc.