Documentation for module cp_linked_list_fm

...

source: cp_linked_list_fm.F
Loading...

public Types:

cp_sll_fm_type
represent a single linked list that stores pointers to the elements
cp_sll_fm_p_type
pointer to a linked list (to make arrays of pointers)

Generic procedures:

cp_create
cp_dealloc
cp_get_element_at
cp_get_first_el
cp_get_length
cp_get_rest
cp_insert
cp_next
cp_remove_all
cp_remove_el
cp_remove_first_el
cp_set_element_at
cp_to_array

public Subroutines/Functions:

allocates and initializes a single linked list
SUBROUTINE
cp_sll_fm_dealloc (sll)
deallocates the singly linked list starting at sll. Does not work if loops are present!
returns the element at the given index
returns the first element stored in the list
FUNCTION
INTEGER
cp_sll_fm_get_length (sll)
returns the length of the list
returns the rest of the list
SUBROUTINE
cp_sll_fm_insert_el (sll, el)
insert an element at the beginning of the list
inserts the element at the given index
FUNCTION
LOGICAL
cp_sll_fm_next (iterator, el_att)
returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next element
removes all the elements from the list
removes the element at the given index
remove the first element of the linked list
sets the element at the given index
returns a newly allocated array with the same contents as the linked list

public Types:

TYPE :: cp_sll_fm_p_type

pointer to a linked list (to make arrays of pointers)


POINTER :: list the pointer to the list

TYPE :: cp_sll_fm_type

represent a single linked list that stores pointers to the elements


TYPE(cp_fm_type),
POINTER :: first_el the element that is stored in this node.
POINTER :: rest the rest of the list


Generic procedure cp_create

allocates and initializes a single linked list

POINTER
:: sll ×
TYPE(cp_fm_type),
POINTER, OPTIONAL
:: first_el ×
POINTER, OPTIONAL
:: rest ×

Generic procedure cp_dealloc

deallocates the singly linked list starting at sll. Does not work if loops are present!

POINTER
:: sll ×

Generic procedure cp_get_element_at

returns the element at the given index

POINTER
:: sll ×
INTEGER,
INTENT(in)
:: index ×

Generic procedure cp_get_first_el

returns the first element stored in the list

POINTER
:: sll ×

Generic procedure cp_get_length

returns the length of the list

POINTER
:: sll ×

Generic procedure cp_get_rest

returns the rest of the list

POINTER
:: sll ×
INTEGER,
OPTIONAL
:: iter ×

Generic procedure cp_insert

insert an element at the beginning of the list

POINTER
:: sll ×
TYPE(cp_fm_type),
POINTER
:: el ×

Generic procedure cp_next

returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next element

POINTER
:: iterator ×
TYPE(cp_fm_type),
POINTER, OPTIONAL
:: el_att ×

Generic procedure cp_remove_all

removes all the elements from the list

POINTER
:: sll ×

Generic procedure cp_remove_el

...

POINTER
:: sll × ×
INTEGER,
INTENT(in)
:: index ×

Generic procedure cp_remove_first_el

remove the first element of the linked list

POINTER
:: sll ×

Generic procedure cp_set_element_at

sets the element at the given index

POINTER
:: sll ×
INTEGER,
INTENT(in)
:: index ×
TYPE(cp_fm_type),
POINTER
:: value ×

Generic procedure cp_to_array

returns a newly allocated array with the same contents as the linked list

POINTER
:: sll ×

SUBROUTINEcp_sll_fm_create(sll, first_el, rest)

allocates and initializes a single linked list

Arguments:
POINTER
:: sll the single linked list to initialize
TYPE(cp_fm_type),
POINTER, OPTIONAL
:: first_el the first element of this list
POINTER, OPTIONAL
:: rest the following elements (if not given: empty)

SUBROUTINEcp_sll_fm_dealloc(sll)

deallocates the singly linked list starting at sll. Does not work if loops are present!

Arguments:
POINTER
:: sll the list to be deallocated

FUNCTIONcp_sll_fm_get_el_at(sll, index)

returns the element at the given index

Return Value ::
Arguments:
POINTER
:: sll the list you get the element from
INTEGER,
INTENT(in)
:: index the position of the element (stating at 1)

FUNCTIONcp_sll_fm_get_first_el(sll)

returns the first element stored in the list

Return Value ::
Arguments:
POINTER
:: sll the single linked list to get the element from

FUNCTIONcp_sll_fm_get_length(sll)

returns the length of the list

Return Value ::
INTEGER
Arguments:
POINTER
:: sll the list you want to know the length of

FUNCTIONcp_sll_fm_get_rest(sll, iter)

returns the rest of the list

Return Value ::
Arguments:
POINTER
:: sll the single linked list to get the rest from
INTEGER,
OPTIONAL
:: iter how many times the call to rest should be iterated, defaults to 1; -1 means till end of the list.

SUBROUTINEcp_sll_fm_insert_el(sll, el)

insert an element at the beginning of the list

Arguments:
POINTER
:: sll the single linked list point at the beginning of which you want to add the element
TYPE(cp_fm_type),
POINTER
:: el the element to add

SUBROUTINEcp_sll_fm_insert_el_at(sll, el, index)

inserts the element at the given index

Arguments:
POINTER
:: sll the list you get the element from
TYPE(cp_fm_type),
POINTER
:: el the new element
INTEGER,
INTENT(in)
:: index the position of the element (stating at 1). If it is -1, it means at end

FUNCTIONcp_sll_fm_next(iterator, el_att)

returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next element

Return Value ::
LOGICAL
Arguments:
POINTER
:: iterator iterator that moves along the list
TYPE(cp_fm_type),
POINTER, OPTIONAL
:: el_att the actual element (valid only if the function returns true)

SUBROUTINEcp_sll_fm_rm_all_el(sll)

removes all the elements from the list

Arguments:
POINTER
:: sll the list that should be removed

SUBROUTINEcp_sll_fm_rm_el_at(sll, index)

removes the element at the given index

Arguments:
POINTER
:: sll the list you get the element from
INTEGER,
INTENT(in)
:: index the position of the element (stating at 1)

SUBROUTINEcp_sll_fm_rm_first_el(sll)

remove the first element of the linked list

Arguments:
POINTER
:: sll the list whose first element has to be removed

SUBROUTINEcp_sll_fm_set_el_at(sll, index, value)

sets the element at the given index

Arguments:
POINTER
:: sll the list you get the element from
INTEGER,
INTENT(in)
:: index the position of the element (stating at 1) -1 means at the end
TYPE(cp_fm_type),
POINTER
:: value the new element

FUNCTIONcp_sll_fm_to_array(sll)

returns a newly allocated array with the same contents as the linked list

Return Value ::
Arguments:
POINTER
:: sll the list to trasform in array