Generic searching and sorting routines.
Add elements to a vector in chunks.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(item), | intent(inout), | dimension(:), allocatable | :: | vec | ||
| integer, | intent(inout) | :: | n |
counter for last element added to |
||
| integer, | intent(in) | :: | chunk_size |
allocate |
||
| class(item), | intent(in), | optional | :: | val |
the value to add to |
|
| logical, | intent(in), | optional | :: | finished |
set to true to return |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(inout), | dimension(:), allocatable | :: | vec | ||
| integer, | intent(inout) | :: | n |
counter for last element added to |
||
| integer, | intent(in) | :: | chunk_size |
allocate |
||
| integer(kind=int32), | intent(in), | optional | :: | val |
the value to add to |
|
| logical, | intent(in), | optional | :: | finished |
set to true to return |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(inout), | dimension(:), allocatable | :: | vec | ||
| integer, | intent(inout) | :: | n |
counter for last element added to |
||
| integer, | intent(in) | :: | chunk_size |
allocate |
||
| integer(kind=int64), | intent(in), | optional | :: | val |
the value to add to |
|
| logical, | intent(in), | optional | :: | finished |
set to true to return |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(inout), | dimension(:), allocatable | :: | vec | ||
| integer, | intent(inout) | :: | n |
counter for last element added to |
||
| integer, | intent(in) | :: | chunk_size |
allocate |
||
| real(kind=real64), | intent(in), | optional | :: | val |
the value to add to |
|
| logical, | intent(in), | optional | :: | finished |
set to true to return |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(inout), | dimension(:), allocatable | :: | vec | ||
| integer, | intent(inout) | :: | n |
counter for last element added to |
||
| integer, | intent(in) | :: | chunk_size |
allocate |
||
| real(kind=real32), | intent(in), | optional | :: | val |
the value to add to |
|
| logical, | intent(in), | optional | :: | finished |
set to true to return |
Returns only the unique elements of the vector.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(item), | intent(in), | dimension(:) | :: | vec |
a vector of items |
|
| class(item), | intent(out), | dimension(:), allocatable | :: | vec_unique |
unique elements of |
|
| integer, | intent(in), | optional | :: | chunk_size |
chunk size for expanding arrays. if not present, default is 100. |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in), | dimension(:) | :: | vec |
a vector |
|
| integer(kind=int32), | intent(out), | dimension(:), allocatable | :: | vec_unique |
unique elements of |
|
| integer, | intent(in), | optional | :: | chunk_size |
chunk size for expanding arrays. if not present, default is 100. |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in), | dimension(:) | :: | vec |
a vector |
|
| integer(kind=int64), | intent(out), | dimension(:), allocatable | :: | vec_unique |
unique elements of |
|
| integer, | intent(in), | optional | :: | chunk_size |
chunk size for expanding arrays. if not present, default is 100. |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in), | dimension(:) | :: | vec |
a vector |
|
| real(kind=real64), | intent(out), | dimension(:), allocatable | :: | vec_unique |
unique elements of |
|
| integer, | intent(in), | optional | :: | chunk_size |
chunk size for expanding arrays. if not present, default is 100. |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(in), | dimension(:) | :: | vec |
a vector |
|
| real(kind=real32), | intent(out), | dimension(:), allocatable | :: | vec_unique |
unique elements of |
|
| integer, | intent(in), | optional | :: | chunk_size |
chunk size for expanding arrays. if not present, default is 100. |
Sorts an array in increasing order.
Uses a basic recursive quicksort (with insertion sort for partitions with 20 elements). Replaces the original array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(item), | intent(inout), | dimension(:) | :: | vec |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(inout), | dimension(:) | :: | vec |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(inout), | dimension(:) | :: | vec |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(inout), | dimension(:) | :: | vec |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(inout), | dimension(:) | :: | vec |
Sorts an array in decreasing order.
Uses a basic recursive quicksort (with insertion sort for partitions with 20 elements). Replaces the original array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(item), | intent(inout), | dimension(:) | :: | vec |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(inout), | dimension(:) | :: | vec |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(inout), | dimension(:) | :: | vec |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(inout), | dimension(:) | :: | vec |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(inout), | dimension(:) | :: | vec |
Binary search of a sorted array. (assumed to be in ascending order)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(item), | intent(in) | :: | val |
value to match in |
||
| class(item), | intent(in), | dimension(:) | :: | vec |
array to search (it is assumed to be sorted) |
the first matched index in vec
(if not found, 0 is returned)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | val |
value to match in |
||
| integer(kind=int32), | intent(in), | dimension(:) | :: | vec |
array to search (it is assumed to be sorted) |
the first matched index in vec
(if not found, 0 is returned)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | val |
value to match in |
||
| integer(kind=int64), | intent(in), | dimension(:) | :: | vec |
array to search (it is assumed to be sorted) |
the first matched index in vec
(if not found, 0 is returned)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | val |
value to match in |
||
| real(kind=real64), | intent(in), | dimension(:) | :: | vec |
array to search (it is assumed to be sorted) |
the first matched index in vec
(if not found, 0 is returned)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(in) | :: | val |
value to match in |
||
| real(kind=real32), | intent(in), | dimension(:) | :: | vec |
array to search (it is assumed to be sorted) |
the first matched index in vec
(if not found, 0 is returned)
An item to be sorted or searched.
| generic, public :: operator(>) => greater_than | |
| generic, public :: operator(<) => less_than | |
| generic, public :: operator(==) => equal_to | |
| generic, public :: assignment(=) => assign_equal | |
| procedure(greater_than_func), public, deferred :: greater_than | |
| procedure(less_than_func), public, deferred :: less_than | |
| procedure(equal_to_func), public, deferred :: equal_to | |
| procedure(assign_equal_func), public, deferred :: assign_equal |