Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

A way to get a pointer to a linked list item

Moderators: kris

Posted: 06/13/08 00:05:23

I've had a look at the new container package, primarily tango.util.container.LinkedList?.

I'm wondering if it would be possible to add a way to get a pointer to value. Doesn't look like it is currently. Indigo has iterators that has .value and .ptr fields, that's one way of doing this.

While I understand that there might be reasons for not doing this, here's my use case:

I have a GUI app that displays data while loading it. Which items are displayed depends on filter settings, and they are inserted in sorted order (it's a game server browser). The data for each item (server) is kept in a struct.

An array of pointers to ServerData? structs represents the filtered and sorted view of the main data structure. Currently I'm using a dynamic array for the main data structure, but this causes a lot of reallocation and copying, since I can't always tell how many items there will be, otherwise I could just preallocate.

I could use some kind of block allocation system, or just make a simple linked list implementation myself. But being able to use tango's LinkedList? would be nice too.

There are no responses to display.