Module to provide dynamic structures for treeID elements
The dynamic arrays provided by this module are capable of handling lists of values, which might need to grow over time. Removal of entries is not possible directly. A ranking list for the indices is maintained to fast lookups of given values by a binary search. This allows for the efficient handling of lists with unique entries. The complete module might be put into a CoCo Text template, to create new modules of this object for different types. For now, two different templates are used for the declaration part and the implementation part.
This function provides the test for equality of two treeIDs.
Two treeIDs are equal if their integer is equal
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is equal??
This function provides the test for unequality of two path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is unequal??
This function provides a comparison of two paths.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is smaller??
This function provides a comparison of two paths.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is smaller??
This function provides a comparison of two paths.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is greater??
This function provides a comparison of two paths.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is greater??
initialize the dynamic array
Include the subroutines for the dynamic array. initialization of a dynamic array
before a dynamic array can be used, it has to be initialized with this routine. the initial length provided here, can avoid reallocations and memory copying, if approximated correctly enough. if none is specified, the provided container initially will be of size 0.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type), | intent(out) | :: | me | |||
integer, | intent(in), | optional | :: | length |
destroy the dynamic array
destruction of a dynamic array
this subroutine takes care of a proper destruction of a dynamic array, it frees the allocated memory and resets the internal counts to 0.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type), | intent(inout) | :: | me |
append a value to the dynamic array and return its position.
appending a value to the dynamic array
with this subroutine, a given value can be added to the dynamic array. the actual position of this value in the dynamic array will be returned, so it can be found again easily later. with the wasadded flag, it is indicated,\n wasadded = true, if this entry had to be added,\n wasadded = false, if this was already found in the array.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me | ||||
type(tem_path_type), | intent(in) | :: | val | |||
integer, | intent(in), | optional | :: | length |
optional length to expand the array |
|
integer, | intent(out), | optional | :: | pos |
position in the array, if the value is found |
|
logical, | intent(out), | optional | :: | wasadded |
flag to indicate, if val was newly added |
appending a sorted list of values to the dynamic array
with this subroutine, a given list of sorted values can be added to the dynamic array. the actual positions of these values in the dynamic array will be returned, so it can be found again easily later. with the wasadded flag, it is indicated,\n wasadded = true, if this entry had to be added,\n wasadded = false, if this was already found in the array.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me | ||||
type(tem_path_type), | intent(in) | :: | val(:) | |||
integer, | intent(in), | optional | :: | length |
optional length to expand the array |
|
integer, | intent(out), | optional | :: | pos(:) |
position in the array, the values are found at. |
|
logical, | intent(out), | optional | :: | wasadded(:) |
flag to indicate, if val was newly added |
truncate the array, meaning cut off the trailing empty entries
truncate the array after the last valid entry and hence cut off the empty trailing empty entries
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me |
empty the array, reset nvals to be 0
empty all contents of the array without changing the size or status of any array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me |
fix the dynamic array, meaning: store the array in the sorted order and cut off the trailing empty entries
fixing the dynamic array
truncate the array after the last valid entry and hence cut off the empty trailing empty entries store the array in the sorted order according to the sorted( ) array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me |
increase the size of the container for the array.
expanding the dynamic array
this is a helping subroutine, which doubles the container of the given dynamic array. as the container might be initially 0-sized, a module variable minlength has been introduced, which is used here, to at least create a container of this size.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me | ||||
integer, | optional | :: | increment | |||
integer, | intent(in), | optional | :: | length |
optional length to expand the array |
return the position of a given value in the array val, which is what you usually want to know. it is the index of a given value
the actual position of a given value in the dynamic array
most likely this is what you need in codes, using this data structure, it first does the binary search on the sorted values with sortposofval_path and then returns the looked up position in the original unsorted array, which corresponds to the position returned by the append routine.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type), | intent(in) | :: | me | |||
type(tem_path_type), | intent(in) | :: | val | |||
logical, | intent(in), | optional | :: | nextifnotfound |
flag to indicate, if the position of the next entry in the sorted list should be returned instead, if val is not found. |
|
integer, | intent(in), | optional | :: | lower | ||
integer, | intent(in), | optional | :: | upper |
return the position of a given value in the list 'sorted'. this is mainly for internal usage. the sorted list is only a pointer list to the actual values thus, in order to get the index of a given value, you need to look up the entry in the sorted list. this is done by the positionofval routine
return the sorted position of a value in the given dynamic array
if the value was not found, - return 0 if nextifnotfound = .false. - return position at the end if nextifnotfound = .true.
binary search on sorted list
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type), | intent(in) | :: | me | |||
type(tem_path_type), | intent(in) | :: | val | |||
logical, | intent(in), | optional | :: | nextifnotfound |
flag to indicate, if the next entry in the list should be returned, if the searched one is not found. |
|
integer, | intent(in), | optional | :: | lower | ||
integer, | intent(in), | optional | :: | upper |
dynamic array (da) type for type(tem_path_type)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | nvals | = | 0 | ||
integer, | public | :: | containersize | = | 0 | ||
type(tem_path_type), | public, | allocatable | :: | val(:) | |||
integer, | public, | allocatable | :: | sorted(:) |
return the sorted position of a value in the given dynamic array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type), | intent(in) | :: | me | |||
type(tem_path_type), | intent(in) | :: | val | |||
logical, | intent(in), | optional | :: | nextifnotfound |
flag to indicate, if the next entry in the list should be returned, if the searched one is not found. |
|
integer, | intent(in), | optional | :: | lower | ||
integer, | intent(in), | optional | :: | upper |
the actual position of a given value in the dynamic array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type), | intent(in) | :: | me | |||
type(tem_path_type), | intent(in) | :: | val | |||
logical, | intent(in), | optional | :: | nextifnotfound |
flag to indicate, if the position of the next entry in the sorted list should be returned instead, if val is not found. |
|
integer, | intent(in), | optional | :: | lower | ||
integer, | intent(in), | optional | :: | upper |
This function provides the test for equality of two treeIDs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is equal??
This function provides the test for unequality of two path.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is unequal??
This function provides a comparison of two paths.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is smaller??
This function provides a comparison of two paths.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is smaller??
This function provides a comparison of two paths.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is greater??
This function provides a comparison of two paths.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
path to compare |
||
type(tem_path_type), | intent(in) | :: | right |
path to compare against |
is greater??
Include the subroutines for the dynamic array. initialization of a dynamic array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type), | intent(out) | :: | me | |||
integer, | intent(in), | optional | :: | length |
destruction of a dynamic array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type), | intent(inout) | :: | me |
appending a value to the dynamic array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me | ||||
type(tem_path_type), | intent(in) | :: | val | |||
integer, | intent(in), | optional | :: | length |
optional length to expand the array |
|
integer, | intent(out), | optional | :: | pos |
position in the array, if the value is found |
|
logical, | intent(out), | optional | :: | wasadded |
flag to indicate, if val was newly added |
appending a sorted list of values to the dynamic array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me | ||||
type(tem_path_type), | intent(in) | :: | val(:) | |||
integer, | intent(in), | optional | :: | length |
optional length to expand the array |
|
integer, | intent(out), | optional | :: | pos(:) |
position in the array, the values are found at. |
|
logical, | intent(out), | optional | :: | wasadded(:) |
flag to indicate, if val was newly added |
truncate the array after the last valid entry and hence cut off the empty trailing empty entries
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me |
empty all contents of the array without changing the size or status of any array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me |
fixing the dynamic array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me |
expanding the dynamic array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_patharray_type) | :: | me | ||||
integer, | optional | :: | increment | |||
integer, | intent(in), | optional | :: | length |
optional length to expand the array |