Module that contains the implementation of a single row of nodes in the linked-list matrix representation.
Linked list for a given row index, contains the column values
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | nb_elements | number of elements in linked list |
|||
type(node_t), | public, | pointer | :: | head | pointer to head (first element added) |
||
type(node_t), | public, | pointer | :: | tail | pointer to tail (last element added) |
procedure, public :: add_node | |
procedure, public :: get_node | |
procedure, public :: delete_row | |
procedure, public :: delete_node_from_row | |
procedure, private :: create_first_node | |
procedure, private :: append_node |
Constructor for a new row, initialises the linked list datastructure
and sets the current head and tail pointers to null()
.
Returns a pointer to the node corresponding to the given column. Returns a nullified pointer if no node containing the given column index was found.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(row_t), | intent(in) | :: | this | type instance |
||
integer, | intent(in) | :: | column | column index |
the node with a column value that matches column
Adds a new node to the linked list with a given column index and value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(row_t), | intent(inout) | :: | this | type instance |
||
integer, | intent(in) | :: | column | column position of the element |
||
class(*), | intent(in) | :: | element | the element to be added |
Subroutine to add the first node to the linked list. Allocates a new node and sets both the head and tail to this node.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(row_t), | intent(inout) | :: | this | type instance |
||
integer, | intent(in) | :: | column | column position of element |
||
class(*), | intent(in) | :: | element | the element to be added |
Subroutine to append a new node to an already existing list of nodes. A new node is created, appended, and the tail is updated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(row_t), | intent(inout) | :: | this | type instance |
||
integer, | intent(in) | :: | column | column position of element |
||
class(*), | intent(in) | :: | element | the element to be added |
Deletes a given node from the current row.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(row_t), | intent(inout) | :: | this | type instance |
||
integer, | intent(in) | :: | column | column index of node to be deleted |
Deletes a given linked list row by recursively iterating over all nodes. Nullifies the pointers and deallocates the elements.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(row_t), | intent(inout) | :: | this | type instance |