- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to have a list that could grow during execution that would also start with an initial set of values. I could create a static array, but then there's a hard upper bound. I could use an allocatable array, with logic to reallocate if needed, but I can't initialize it at compile time. I could create a linked list, but I can't initialize the next pointers at compile time.Does anyone have any ideas?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use a derived type as the basic element of your list, and then specify default initializations for the components of that derived type. For example, zero for a counter, blank for a string and NULL() for pointers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That wouldn't allow initialization of "next" pointers to point to the next in the list. This is something you'll have to write code to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may want to have a look at the linked list module in my Flibs project at http://flibs.sf.net.
(I should take a closer look at it one of these days, but it is functional andmay give you an
idea of how to go about.)
Regards,
Arjen
(I should take a closer look at it one of these days, but it is functional andmay give you an
idea of how to go about.)
Regards,
Arjen

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page