CP2K 2.4 (Revision 12889)
Classes | Functions | Variables

cp_linked_list_pw Namespace Reference

describes a generic linked list template. Linked list are supposed to always use pointers to the nodes for basically everything: a pointer to the node is a list, an element of the list, an iterator between the elment of the list. An empty list is represented by an unassociated pointer. More...

Classes

interface  cp_create
interface  cp_dealloc
interface  cp_dealloc_node
interface  cp_set
interface  cp_get
interface  cp_next
interface  cp_get_first_el
interface  cp_get_rest
interface  cp_get_empty
interface  cp_get_length
interface  cp_get_element_at
interface  cp_set_element_at
interface  cp_insert
interface  cp_insert_at
interface  cp_remove_el
interface  cp_remove_first_el
interface  cp_remove_all
interface  cp_to_array
struct  cp_sll_pw_type
 represent a single linked list that stores pointers to the elements More...
struct  cp_sll_pw_p_type
 pointer to a linked list (to make arrays of pointers) More...

Functions

subroutine, public cp_sll_pw_create (sll, first_el, rest, error)
 allocates and initializes a single linked list
subroutine, public cp_sll_pw_dealloc (sll, error)
 deallocates the singly linked list starting at sll. Does not work if loops are present!
subroutine, public cp_sll_pw_dealloc_node (sll, error)
 deallocates a node of a singly linked list (low level)
subroutine, public cp_sll_pw_set (sll, first_el, rest, error)
 sets tha various attributes of a single linked list It is an error to set the rest of an empty list without setting the first_el (change and make it simply a sll=>rest ?)
subroutine, public cp_sll_pw_get (sll, first_el, rest, empty, length, error)
 returns various attributes from the linked list
TYPE(pw_type), pointer, public cp_sll_pw_get_first_el (sll, error)
 returns the first element stored in the list
TYPE(cp_sll_pw_type), pointer,
public 
cp_sll_pw_get_rest (sll, iter, error)
 returns the rest of the list
LOGICAL, public cp_sll_pw_get_empty (sll, error)
INTEGER, public cp_sll_pw_get_length (sll, error)
 returns the length of the list
TYPE(pw_type), pointer, public cp_sll_pw_get_el_at (sll, index, error)
 returns the element at the given index
subroutine, public cp_sll_pw_set_el_at (sll, index, value, error)
 sets the element at the given index
LOGICAL, public cp_sll_pw_next (iterator, el_att, error)
 returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next element
subroutine, public cp_sll_pw_insert_el (sll, el, error)
 insert an element at the beginning of the list
subroutine, public cp_sll_pw_rm_first_el (sll, error)
 remove the first element of the linked list
subroutine, public cp_sll_pw_insert_el_at (sll, el, index, error)
 inserts the element at the given index
subroutine, public cp_sll_pw_rm_el_at (sll, index, error)
 removes the element at the given index
subroutine, public cp_sll_pw_rm_all_el (sll, error)
 removes all the elements from the list
TYPE(pw_p_type), dimension(:),
pointer, public 
cp_sll_pw_to_array (sll, error)
 returns a newly allocated array with the same contents as the linked list
TYPE(cp_sll_pw_type), pointer,
public 
cp_sll_pw_from_array (array, error)
 returns a linked list with the same contents as the given array
subroutine, public cp_sll_pw_insert_ordered (sll, el, insert_equals, did_insert, pos, error)
 insert an element mantaining the order
subroutine, public cp_sll_pw_insert_ordered2 (sll, el, compare_function, insert_equals, did_insert, pos, error)
 insert an element mantaining the order defined by a user given function
LOGICAL cp_sll_pw_contains (sll, el, ordered, error)
 returns true if the list contains the given element
function cp_sll_pw_contains2 (sll, el, compare_function, ordered, error)
 returns true if the list contains the given element

Variables

LOGICAL, parameter, private debug_this_module = .TRUE.
CHARACTER(len=*), parameter,
private 
moduleN = 'cp_linked_list_pw'

Detailed Description

describes a generic linked list template. Linked list are supposed to always use pointers to the nodes for basically everything: a pointer to the node is a list, an element of the list, an iterator between the elment of the list. An empty list is represented by an unassociated pointer.

Note:
____ _ _ __ __ _ _ __ _____ _ _ _____ _ _ _ | _ \ ___ _ __ ( ) |_ | \/ | ___ __| (_)/ _|_ _ |_ _| |__ (_)___ | ___(_) | ___| | | | | |/ _ \| '_ \|/| __| | |\/| |/ _ \ / _` | | |_| | | | | | | '_ \| / __| | |_ | | |/ _ \ | | |_| | (_) | | | | | |_ | | | | (_) | (_| | | _| |_| | | | | | | | \ | _| | | | __/_| |____/ /|_| |_| | |_| |_|/ ,_|_|_| , | |_| |_| |_|_|___/ |_| |_|_|(_) |___/ ____ _ ___ _ _ _ _ / ___| | ___ ___ ___ |_ _|_ __ ___ _ __ ___ ___ __| (_) __ _| |_ ___| |_ _ | | | |/ _ \/ __|/ _ \ | || '_ ` _ \| '_ ` _ \ / _ \/ _` | |/ _` | __/ _ \ | | | | | |___| | (_) \ __/ | || | | | | | | | | | | __/ (_| | | (_| | || __/ | |_| | |_|/|___/| |___|_| |_| |_|_| |_| |_||,_|_|,_||_|, | |___/ _____ _ _ _____ _ _ _ |_ _| |__ (_)___ | ___(_) | ___| | | | | '_ \| / __| | |_ | | |/ _ \ | | | | | | | \ | _| | | | __/_| |_| |_| |_|_|___/ |_| |_|_|(_)

This is a template

**** DO NOT MODIFY THE .F FILES **** modify the .template and .instantition instead

History
1.2002 created 4.2002 changed most of the methods, by making access to the list always through pointers (identifying pointer, list and iterators) 6.2004 removed initialized from list elements
Author:
Fawzi Mohamed

Function Documentation

LOGICAL cp_linked_list_pw::cp_sll_pw_contains ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),pointer  el,
LOGICAL,intent(in),optional  ordered,
TYPE(cp_error_type),intent(inout)  error 
)

returns true if the list contains the given element

Parameters:
sllthe linked list you want to control
elthe element to control
orderedif true assumes that the list is ordered in growing order. (defaults to false)
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
marginally faster if ordered (n/2 instread of n)
History
07.2002 created [fawzi]
Author:
Fawzi Mohamed

Definition at line 1076 of file cp_linked_list_pw.f90.

References cp_sll_pw_next().

Here is the call graph for this function:

function cp_linked_list_pw::cp_sll_pw_contains2 ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),pointer  el,
compare_function  compare_function,
LOGICAL,intent(in),optional  ordered,
TYPE(cp_error_type),intent(inout)  error 
) [private]

returns true if the list contains the given element

Parameters:
sllthe linked list you want to control
elthe element to control
compare_functiona function used to compare two elements, it should return a negative number if the first argument is less than the second, 0 if they are equal, otherwise a positive number
orderedif true assumes that the list is ordered in growing order. (defaults to false)
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
marginally faster if ordered (n/2 instread of n)
History
07.2002 created [fawzi]
Author:
Fawzi Mohamed

Definition at line 1131 of file cp_linked_list_pw.f90.

subroutine,public cp_linked_list_pw::cp_sll_pw_create ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),optional,pointer  first_el,
TYPE(cp_sll_pw_type),optional,pointer  rest,
TYPE(cp_error_type),intent(inout)  error 
)

allocates and initializes a single linked list

Parameters:
sllthe single linked list to initialize
first_elthe first element of this list
restthe following elements (if not given: empty)
errorvariable to control error logging, stopping,... see module cp_error_handling
History
none
Author:
Fawzi Mohamed

Definition at line 220 of file cp_linked_list_pw.f90.

References CPPostcondition.

Referenced by compare_function::compare_function(), cp_sll_pw_from_array(), cp_sll_pw_insert_el(), cp_sll_pw_insert_ordered(), and cp_sll_pw_set().

Here is the caller graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_dealloc ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(cp_error_type),intent(inout)  error 
)

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

Parameters:
sllthe list to be deallocated
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
does not deallocate the elments that are stored in the list check more?
History
none
Author:
Fawzi Mohamed

Definition at line 262 of file cp_linked_list_pw.f90.

References cp_sll_pw_rm_all_el().

Referenced by pw_pool_types::pw_pool_flush_cache().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_dealloc_node ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(cp_error_type),intent(inout)  error 
)

deallocates a node of a singly linked list (low level)

Parameters:
sllthe node to be deallocated
errorvariable to control error logging, stopping,... see module cp_error_handling
History
none
Author:
Fawzi Mohamed

Definition at line 283 of file cp_linked_list_pw.f90.

References CPPostcondition.

Referenced by cp_sll_pw_rm_all_el(), and cp_sll_pw_rm_first_el().

Here is the caller graph for this function:

TYPE(cp_sll_pw_type),pointer,public cp_linked_list_pw::cp_sll_pw_from_array ( TYPE(pw_p_type),dimension(:),intent(in)  array,
TYPE(cp_error_type),intent(inout)  error 
)

returns a linked list with the same contents as the given array

Parameters:
arraythe array you want to copy
errorvariable to control error logging, stopping,... see module cp_error_handling
History
07.2002 created [fawzi]
Author:
Fawzi Mohamed

Definition at line 876 of file cp_linked_list_pw.f90.

References cp_sll_pw_create().

Here is the call graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_get ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),optional,pointer  first_el,
TYPE(cp_sll_pw_type),optional,pointer  rest,
LOGICAL,intent(out),optional  empty,
INTEGER,intent(out),optional  length,
TYPE(cp_error_type),intent(inout)  error 
)

returns various attributes from the linked list

Parameters:
sllthe single linked list to change
first_elthe first element of this list (can be unassociated)
restthe rest of the list (can be unassociated)
lengththe length of the list
errorvariable to control error logging, stopping,... see module cp_error_handling
History
none
Author:
Fawzi Mohamed

Definition at line 351 of file cp_linked_list_pw.f90.

References cp_sll_pw_get_length().

Here is the call graph for this function:

TYPE(pw_type),pointer,public cp_linked_list_pw::cp_sll_pw_get_el_at ( TYPE(cp_sll_pw_type),pointer  sll,
INTEGER,intent(in)  index,
TYPE(cp_error_type),intent(inout)  error 
)

returns the element at the given index

Parameters:
sllthe list you get the element from
indexthe position of the element (stating at 1)
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
slow (O(index))
History
none
Author:
Fawzi Mohamed

Definition at line 538 of file cp_linked_list_pw.f90.

References cp_sll_pw_get_rest().

Here is the call graph for this function:

LOGICAL,public cp_linked_list_pw::cp_sll_pw_get_empty ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(cp_error_type),intent(inout)  error 
)
Parameters:
sllthe single linked list to get the rest from
errorvariable to control error logging, stopping,... see module cp_error_handling
History
none
Author:
Fawzi Mohamed

Definition at line 475 of file cp_linked_list_pw.f90.

TYPE(pw_type),pointer,public cp_linked_list_pw::cp_sll_pw_get_first_el ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(cp_error_type),intent(inout)  error 
)

returns the first element stored in the list

Parameters:
sllthe single linked list to get the element from
errorvariable to control error logging, stopping,... see module cp_error_handling
History
none
Author:
Fawzi Mohamed

Definition at line 389 of file cp_linked_list_pw.f90.

INTEGER,public cp_linked_list_pw::cp_sll_pw_get_length ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(cp_error_type),intent(inout)  error 
)

returns the length of the list

Parameters:
sllthe list you want to know the length of
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
slow (O(n))
History
none
Author:
Fawzi Mohamed

Definition at line 501 of file cp_linked_list_pw.f90.

Referenced by cp_sll_pw_get(), and cp_sll_pw_to_array().

Here is the caller graph for this function:

TYPE(cp_sll_pw_type),pointer,public cp_linked_list_pw::cp_sll_pw_get_rest ( TYPE(cp_sll_pw_type),pointer  sll,
INTEGER,optional  iter,
TYPE(cp_error_type),intent(inout)  error 
)

returns the rest of the list

Parameters:
sllthe single linked list to get the rest from
iterhow many times the call to rest should be iterated, defaults to 1; -1 means till end of the list.
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
split the case iter=1 to make it more optimized?
History
none
Author:
Fawzi Mohamed

Definition at line 422 of file cp_linked_list_pw.f90.

Referenced by cp_sll_pw_get_el_at(), cp_sll_pw_insert_el_at(), cp_sll_pw_rm_el_at(), and cp_sll_pw_set_el_at().

Here is the caller graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_insert_el ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),pointer  el,
TYPE(cp_error_type),intent(inout)  error 
)

insert an element at the beginning of the list

Parameters:
sllthe single linked list point at the beginning of which you want to add the element
elthe element to add
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
fast (O(1))
History
none
Author:
Fawzi Mohamed

Definition at line 655 of file cp_linked_list_pw.f90.

References cp_sll_pw_create().

Referenced by compare_function::compare_function(), cp_sll_pw_insert_el_at(), and cp_sll_pw_insert_ordered().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_insert_el_at ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),pointer  el,
INTEGER,intent(in)  index,
TYPE(cp_error_type),intent(inout)  error 
)

inserts the element at the given index

Parameters:
sllthe list you get the element from
indexthe position of the element (stating at 1). If it is -1, it means at end
elthe new element
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
slow (O(index))
History
none
Author:
Fawzi Mohamed

Definition at line 723 of file cp_linked_list_pw.f90.

References cp_sll_pw_get_rest(), and cp_sll_pw_insert_el().

Here is the call graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_insert_ordered ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),pointer  el,
LOGICAL,intent(in),optional  insert_equals,
LOGICAL,intent(out),optional  did_insert,
TYPE(cp_sll_pw_type),optional,pointer  pos,
TYPE(cp_error_type),intent(inout)  error 
)

insert an element mantaining the order

Parameters:
sllthe list you want to insert in
elthe element that you want to insert
insert_equalsif equal elements should be inserted (defaults to false)
did_inserttrue if it did insert the element
posnode where the element has been inserted (or of the same element that was already in the list)
errorvariable to control error logging, stopping,... see module cp_error_handling
History
07.2002 created [fawzi]
Author:
Fawzi Mohamed

Definition at line 921 of file cp_linked_list_pw.f90.

References cp_sll_pw_create(), cp_sll_pw_insert_el(), cp_sll_pw_next(), CPAssert, CPInvariant, and error.

Here is the call graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_insert_ordered2 ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),pointer  el,
compare_function  compare_function,
LOGICAL,intent(in),optional  insert_equals,
LOGICAL,intent(out),optional  did_insert,
TYPE(cp_sll_pw_type),optional,pointer  pos,
TYPE(cp_error_type),intent(inout)  error 
)

insert an element mantaining the order defined by a user given function

Parameters:
sllthe list you want to insert in
elthe element that you want to insert
compare_functiona function used to compare two elements, it should return a negative number if the first argument is less than the second, 0 if they are equal, otherwise a positive number
insert_equalsif equal elements should be inserted (defaults to false)
errorvariable to control error logging, stopping,... see module cp_error_handling
History
07.2002 created [fawzi]
Author:
Fawzi Mohamed

Definition at line 992 of file cp_linked_list_pw.f90.

References error.

LOGICAL,public cp_linked_list_pw::cp_sll_pw_next ( TYPE(cp_sll_pw_type),pointer  iterator,
TYPE(pw_type),optional,pointer  el_att,
TYPE(cp_error_type),intent(inout)  error 
)

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

Parameters:
iteratoriterator that moves along the list
errorvariable to control error logging, stopping,... see module cp_error_handling
el_attthe actual element (valid only if the function returns true)
History
none
Author:
Fawzi Mohamed

Definition at line 618 of file cp_linked_list_pw.f90.

Referenced by compare_function::compare_function(), cp_sll_pw_contains(), cp_sll_pw_insert_ordered(), and cp_sll_pw_to_array().

Here is the caller graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_rm_all_el ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(cp_error_type),intent(inout)  error 
)

removes all the elements from the list

Parameters:
sllthe list that should be removed
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
check more?
History
none
Author:
Fawzi Mohamed

Definition at line 807 of file cp_linked_list_pw.f90.

References cp_sll_pw_dealloc_node().

Referenced by cp_sll_pw_dealloc().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_rm_el_at ( TYPE(cp_sll_pw_type),pointer  sll,
INTEGER,intent(in)  index,
TYPE(cp_error_type),intent(inout)  error 
)

removes the element at the given index

Parameters:
sllthe list you get the element from
indexthe position of the element (stating at 1)
elthe new element
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
slow (O(index))
History
none
Author:
Fawzi Mohamed

Definition at line 765 of file cp_linked_list_pw.f90.

References cp_sll_pw_get_rest(), and cp_sll_pw_rm_first_el().

Here is the call graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_rm_first_el ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(cp_error_type),intent(inout)  error 
)

remove the first element of the linked list

Parameters:
sllthe list whose first element has to be removed
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
fast (O(1))
History
none
Author:
Fawzi Mohamed

Definition at line 685 of file cp_linked_list_pw.f90.

References cp_sll_pw_dealloc_node().

Referenced by cp_sll_pw_rm_el_at().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_set ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(pw_type),optional,pointer  first_el,
TYPE(cp_sll_pw_type),optional,pointer  rest,
TYPE(cp_error_type),intent(inout)  error 
)

sets tha various attributes of a single linked list It is an error to set the rest of an empty list without setting the first_el (change and make it simply a sll=>rest ?)

Parameters:
sllthe single linked list to change
first_elthe element to replace the first element of this list
restthe rest of the list (can be unassociated)
errorvariable to control error logging, stopping,... see module cp_error_handling
History
none
Author:
Fawzi Mohamed

Definition at line 314 of file cp_linked_list_pw.f90.

References cp_sll_pw_create(), and CPAssert.

Here is the call graph for this function:

subroutine,public cp_linked_list_pw::cp_sll_pw_set_el_at ( TYPE(cp_sll_pw_type),pointer  sll,
INTEGER,intent(in)  index,
TYPE(pw_type),pointer  value,
TYPE(cp_error_type),intent(inout)  error 
)

sets the element at the given index

Parameters:
sllthe list you get the element from
indexthe position of the element (stating at 1) -1 means at the end
valuethe new element
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
slow (O(index))
History
none
Author:
Fawzi Mohamed

Definition at line 580 of file cp_linked_list_pw.f90.

References cp_sll_pw_get_rest().

Here is the call graph for this function:

TYPE(pw_p_type),dimension(:),pointer,public cp_linked_list_pw::cp_sll_pw_to_array ( TYPE(cp_sll_pw_type),pointer  sll,
TYPE(cp_error_type),intent(inout)  error 
)

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

Parameters:
sllthe list to trasform in array
errorvariable to control error logging, stopping,... see module cp_error_handling
History
07.2002 created [fawzi]
Author:
Fawzi Mohamed

Definition at line 839 of file cp_linked_list_pw.f90.

References cp_sll_pw_get_length(), cp_sll_pw_next(), CPAssert, and CPPostcondition.

Here is the call graph for this function:


Variable Documentation

LOGICAL,parameter,private cp_linked_list_pw::debug_this_module = .TRUE.

Definition at line 58 of file cp_linked_list_pw.f90.

CHARACTER(len=*),parameter,private cp_linked_list_pw::moduleN = 'cp_linked_list_pw'

Definition at line 59 of file cp_linked_list_pw.f90.