Arrays of pointers

AmadanMath_at_gmail.com
Date: 01/27/05


Date: 27 Jan 2005 08:20:32 -0800

Hello.

I am rather new at FORTRAN, and I have a problem with the type system
(F90). I have a binary tree type:

TYPE tree
TYPE (tree), POINTER :: left, right
...
END TYPE tree

and I usually do:

TYPE (tree), POINTER :: my_tree
my_tree => build_tree(...)

where new_tree allocates space for it and constructs the tree. Now I
need several trees in a dynamically allocated array, but I cannot make
an array of pointers. I could probably refactor my code so that
build_tree works on an already allocated object, so that it does not
require a pointer, but is there some way I could really have an
(allocatable) array of pointers to my structure?
Thanks a lot.

Goran Topic



Relevant Pages

  • Re: list optimization
    ... >> i have implemented a list type as an array of pointer like this ... >> to avoid having a pointer for each element as it is done with a recursive ... > Use simply either a linked list or a tree. ... whereas the array solution "only" takes: ...
    (comp.lang.c)
  • Re: Array of pointer,multiple object and struct question?
    ... that returning a pointer to it is a problem? ... The error is returning a pointer to struct ... After creating multiple tree, it return. ... treenode,not an array of treenode ...
    (comp.lang.c)
  • Re: conf files.
    ... as the tree shrinks, short of destroying the tree entirely. ... The struct tree would maintain a pointer to the ... base of this array, and the index of the next free node. ... When you run out of free nodes, you realloc the node block ...
    (comp.unix.programmer)
  • Re: hacker challenge - traverse a list
    ... Here is a little challenge - print the contents of a binary tree ... I assume there are no up links, otherwise the algorithm is trivial. ... space hence unbounded number of bits in a pointer? ... Left branch *not* leaf, rotate: ...
    (comp.programming)
  • Re: question of style
    ... end of the day the quality of the code depends more on the quality of ... or the equivalent null pointer exceptions in Java, C, or whatever? ... But you have implemented a mutable tree. ...     def get: ...
    (comp.lang.python)