CP2K 2.4 (Revision 12889)
Classes | Functions | Variables

cp_linked_list_val 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_val_type
 represent a single linked list that stores pointers to the elements More...
struct  cp_sll_val_p_type
 pointer to a linked list (to make arrays of pointers) More...

Functions

subroutine, public cp_sll_val_create (sll, first_el, rest, error)
 allocates and initializes a single linked list
subroutine, public cp_sll_val_dealloc (sll, error)
 deallocates the singly linked list starting at sll. Does not work if loops are present!
subroutine, public cp_sll_val_dealloc_node (sll, error)
 deallocates a node of a singly linked list (low level)
subroutine, public cp_sll_val_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_val_get (sll, first_el, rest, empty, length, error)
 returns various attributes from the linked list
TYPE(val_type), pointer, public cp_sll_val_get_first_el (sll, error)
 returns the first element stored in the list
TYPE(cp_sll_val_type), pointer,
public 
cp_sll_val_get_rest (sll, iter, error)
 returns the rest of the list
LOGICAL, public cp_sll_val_get_empty (sll, error)
INTEGER, public cp_sll_val_get_length (sll, error)
 returns the length of the list
TYPE(val_type), pointer, public cp_sll_val_get_el_at (sll, index, error)
 returns the element at the given index
subroutine, public cp_sll_val_set_el_at (sll, index, value, error)
 sets the element at the given index
LOGICAL, public cp_sll_val_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_val_insert_el (sll, el, error)
 insert an element at the beginning of the list
subroutine, public cp_sll_val_rm_first_el (sll, error)
 remove the first element of the linked list
subroutine, public cp_sll_val_insert_el_at (sll, el, index, error)
 inserts the element at the given index
subroutine, public cp_sll_val_rm_el_at (sll, index, error)
 removes the element at the given index
subroutine, public cp_sll_val_rm_all_el (sll, error)
 removes all the elements from the list
TYPE(val_p_type), dimension(:),
pointer, public 
cp_sll_val_to_array (sll, error)
 returns a newly allocated array with the same contents as the linked list
TYPE(cp_sll_val_type), pointer,
public 
cp_sll_val_from_array (array, error)
 returns a linked list with the same contents as the given array
subroutine, public cp_sll_val_insert_ordered (sll, el, insert_equals, did_insert, pos, error)
 insert an element mantaining the order
subroutine, public cp_sll_val_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_val_contains (sll, el, ordered, error)
 returns true if the list contains the given element
function cp_sll_val_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_val'

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_val::cp_sll_val_contains ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_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 1071 of file cp_linked_list_val.f90.

References cp_sll_val_next().

Here is the call graph for this function:

function cp_linked_list_val::cp_sll_val_contains2 ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_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 1126 of file cp_linked_list_val.f90.

subroutine,public cp_linked_list_val::cp_sll_val_create ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_type),optional,pointer  first_el,
TYPE(cp_sll_val_type),optional,pointer  rest,
TYPE(cp_error_type),intent(inout)  error 
)
subroutine,public cp_linked_list_val::cp_sll_val_dealloc ( TYPE(cp_sll_val_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 259 of file cp_linked_list_val.f90.

References cp_sll_val_rm_all_el().

Referenced by input_section_types::section_vals_release(), and input_section_types::section_vals_remove_values().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_dealloc_node ( TYPE(cp_sll_val_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 280 of file cp_linked_list_val.f90.

References CPPostcondition.

Referenced by cp_sll_val_rm_all_el(), and cp_sll_val_rm_first_el().

Here is the caller graph for this function:

TYPE(cp_sll_val_type),pointer,public cp_linked_list_val::cp_sll_val_from_array ( TYPE(val_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 873 of file cp_linked_list_val.f90.

References cp_sll_val_create().

Here is the call graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_get ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_type),optional,pointer  first_el,
TYPE(cp_sll_val_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 348 of file cp_linked_list_val.f90.

References cp_sll_val_get_length().

Here is the call graph for this function:

TYPE(val_type),pointer,public cp_linked_list_val::cp_sll_val_get_el_at ( TYPE(cp_sll_val_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 535 of file cp_linked_list_val.f90.

References cp_sll_val_get_rest().

Referenced by input_section_types::section_vals_val_get(), input_section_types::section_vals_val_set(), and input_section_types::section_vals_val_unset().

Here is the call graph for this function:

Here is the caller graph for this function:

LOGICAL,public cp_linked_list_val::cp_sll_val_get_empty ( TYPE(cp_sll_val_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 472 of file cp_linked_list_val.f90.

TYPE(val_type),pointer,public cp_linked_list_val::cp_sll_val_get_first_el ( TYPE(cp_sll_val_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 386 of file cp_linked_list_val.f90.

INTEGER,public cp_linked_list_val::cp_sll_val_get_length ( TYPE(cp_sll_val_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 498 of file cp_linked_list_val.f90.

Referenced by cp_sll_val_get(), cp_sll_val_to_array(), input_section_types::section_vals_val_get(), and input_section_types::section_vals_val_set().

Here is the caller graph for this function:

TYPE(cp_sll_val_type),pointer,public cp_linked_list_val::cp_sll_val_get_rest ( TYPE(cp_sll_val_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 419 of file cp_linked_list_val.f90.

Referenced by cp_sll_val_get_el_at(), cp_sll_val_insert_el_at(), cp_sll_val_rm_el_at(), cp_sll_val_set_el_at(), and input_section_types::section_vals_val_unset().

Here is the caller graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_insert_el ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_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 652 of file cp_linked_list_val.f90.

References cp_sll_val_create().

Referenced by compare_function::compare_function(), cp_sll_val_insert_el_at(), and cp_sll_val_insert_ordered().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_insert_el_at ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_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 720 of file cp_linked_list_val.f90.

References cp_sll_val_get_rest(), and cp_sll_val_insert_el().

Referenced by input_section_types::section_vals_val_set().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_insert_ordered ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_type),pointer  el,
LOGICAL,intent(in),optional  insert_equals,
LOGICAL,intent(out),optional  did_insert,
TYPE(cp_sll_val_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 918 of file cp_linked_list_val.f90.

References cp_sll_val_create(), cp_sll_val_insert_el(), cp_sll_val_next(), CPAssert, CPInvariant, and error.

Here is the call graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_insert_ordered2 ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_type),pointer  el,
compare_function  compare_function,
LOGICAL,intent(in),optional  insert_equals,
LOGICAL,intent(out),optional  did_insert,
TYPE(cp_sll_val_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 989 of file cp_linked_list_val.f90.

References error.

LOGICAL,public cp_linked_list_val::cp_sll_val_next ( TYPE(cp_sll_val_type),pointer  iterator,
TYPE(val_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 615 of file cp_linked_list_val.f90.

Referenced by compare_function::compare_function(), cp_sll_val_contains(), cp_sll_val_insert_ordered(), cp_sll_val_to_array(), force_fields_all::force_field_pack_charges(), md_vel_utils::initialize_cascade(), md_vel_utils::initialize_velocities(), external_potential_types::read_all_potential(), atoms_input::read_atoms_input(), atom_types::read_basis_set(), basis_set_types::read_geminal_basis_set(), external_potential_types::read_gth_potential(), atom_types::read_gth_potential(), basis_set_types::read_gto_basis_set(), atoms_input::read_shell_coord_input(), input_section_types::section_vals_release(), and input_section_types::section_vals_remove_values().

Here is the caller graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_rm_all_el ( TYPE(cp_sll_val_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 804 of file cp_linked_list_val.f90.

References cp_sll_val_dealloc_node().

Referenced by cp_sll_val_dealloc().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_rm_el_at ( TYPE(cp_sll_val_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 762 of file cp_linked_list_val.f90.

References cp_sll_val_get_rest(), and cp_sll_val_rm_first_el().

Referenced by input_section_types::section_vals_val_unset().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_rm_first_el ( TYPE(cp_sll_val_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 682 of file cp_linked_list_val.f90.

References cp_sll_val_dealloc_node().

Referenced by cp_sll_val_rm_el_at().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_set ( TYPE(cp_sll_val_type),pointer  sll,
TYPE(val_type),optional,pointer  first_el,
TYPE(cp_sll_val_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 311 of file cp_linked_list_val.f90.

References cp_sll_val_create(), and CPAssert.

Here is the call graph for this function:

subroutine,public cp_linked_list_val::cp_sll_val_set_el_at ( TYPE(cp_sll_val_type),pointer  sll,
INTEGER,intent(in)  index,
TYPE(val_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 577 of file cp_linked_list_val.f90.

References cp_sll_val_get_rest().

Referenced by input_section_types::section_vals_val_set().

Here is the call graph for this function:

Here is the caller graph for this function:

TYPE(val_p_type),dimension(:),pointer,public cp_linked_list_val::cp_sll_val_to_array ( TYPE(cp_sll_val_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 836 of file cp_linked_list_val.f90.

References cp_sll_val_get_length(), cp_sll_val_next(), CPAssert, and CPPostcondition.

Here is the call graph for this function:


Variable Documentation

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

Definition at line 55 of file cp_linked_list_val.f90.

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

Definition at line 56 of file cp_linked_list_val.f90.