Implements a node which contains a pointer to another (the next) node, allowing a chain to be formed. This can be used to, for example, build linked lists.
It is not anticipated that the linked_node type, or any types extending it, will be handled directly by end users of FIAT; they are meant for internal use within this package.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
class(linked_node), | private, | pointer | :: | next | => | null() | The next node in the chain. |
procedure, public :: has_next | Checks whether this node points to another one |
procedure, public :: get_next | Returns the next node in the chain if it exists. |
procedure, public :: set_next | Sets the next node in the chain. |
procedure, public :: unset_next | Sets this node not to point at any others, severing the chain. |
A node which, in addition to holding a value, points at another (the next) linked_node or descendent type. This type can be built up into a chain, allowing a linked list to be formed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(linked_node), | intent(in) | :: | this |
Returns whether or not this node points at another one, forming a chain.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(linked_node), | intent(in) | :: | this |
Returns a pointer to the node which this ones points to, i.e. the next node in the chain. If this node does not point at another one, then a null pointer is returned.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(linked_node), | intent(inout) | :: | this | |||
class(linked_node), | intent(in), | pointer | :: | new_next | The node which will now be next in the chain. |
|
logical, | intent(in), | optional | :: | deallocate_old | Whether to deallocate (rather than just nullify) any existing
subsequent nodes in the chain. Defaults to |
Sets the node which this one points to (i.e. sets the next node in
the chain). If this node already points to another one, the
pointer will, by default, be nullified. This may result in a
memory leak. Optionally, by setting deallocate_old=.true.
, the
next node (and all nodes it points to) can be deallocated. This
may result in a segfault if another part of the program tries to
access the former next node.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(linked_node), | intent(inout) | :: | this | |||
logical, | intent(in), | optional | :: | deallocate_old | Whether to deallocate (rather than just nullify) any existing
subsequent nodes in the chain. Defaults to |
Unsets the pointer to the next node in the chain, severing it.
By default, the pointer is only nullified. This may result in a
memory leak. Optionally, by setting deallocate_old=.true.
, the
next node (and all nodes it points to) can be deallocated. This
may result in a segfault if another part of the program tries to
access the former next node.