Provides a concrete implementation of the list abstract data type. This implementation, the array_list, stores values in an array and thus fast to read from.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
class(container), | private, | allocatable, dimension(:) | :: | contents | |||
integer, | private | :: | length |
procedure, public :: iter => array_list_iter | |
procedure, public :: contents_type => array_list_contents_type | |
procedure, public :: size => array_list_size | |
procedure, public :: push => array_list_push | |
procedure, public :: pop => array_list_pop | |
procedure, public :: peek => array_list_peek | |
procedure, private :: concat => array_list_concat | |
procedure, public :: clear => array_list_clear | |
procedure, public :: pushleft => array_list_push | |
procedure, public :: pushright => array_list_append | |
procedure, public :: popleft => array_list_popleft | |
procedure, public :: popright => array_list_pop | |
procedure, public :: peekleft => array_list_peekleft | |
procedure, public :: peekright => array_list_peek | |
procedure, public :: append => array_list_append | |
procedure, public :: get => array_list_get | |
procedure, private :: set_single => array_list_set_single | |
procedure, private :: set_multiple => array_list_set_multiple | |
procedure, public :: get_index => array_list_get_index | |
procedure, public :: get_last_index => array_list_get_last_index | |
procedure, public :: get_indices => array_list_get_indices | |
procedure, public :: slice => array_list_slice | |
procedure, public :: foreach => array_list_foreach | |
procedure, public :: insert => array_list_insert | |
procedure, public :: remove => array_list_remove | |
procedure, public :: remove_last => array_list_remove_last | |
procedure, public :: remove_all => array_list_remove_all | |
procedure, private :: delete_single => array_list_delete_single | |
procedure, private :: delete_multiple => array_list_delete_multiple | |
procedure, private :: delete_slice => array_list_delete_slice | |
procedure, public :: has => array_list_has | |
procedure, public :: sort => array_list_sort | |
procedure, public :: min => array_list_min | |
procedure, public :: max => array_list_max | |
procedure, public :: nearest => array_list_nearest | |
procedure, public :: sum => array_list_sum | |
procedure, public :: filter => array_list_filter | |
procedure, public :: to_array => array_list_to_array |
A concrete implementation of the list abstract data type. This implementation stores list contents in an array. It is fast to read from, but it is slow to insert elements into the middle of the list or to add new items to the end (if doing so requires the storage array to be expanded).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this |
Returns an iterator containing the contents of this list as they were at the time this method was called.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this |
Returns a container with the dynamic type of the contents of this list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this |
Returns the number of items in the list
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this |
The value from the end of the list
Removes the item at the end of the list and returns it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this |
The element at the end of the list
Returns the item at the end of the list, without removing it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | lhs | The list |
||
class(ordered), | intent(in) | :: | rhs | The object being concatenated to the list |
The concatenated object. Will have dynamic type array_list.
Join this list with an ordered object, returning the result. The contents of the returned object are ordered such that applying pop until it is empty would return items in the same order as calling pop until the list is empty and then until the second object is empty.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this |
The item just removed from the start of the list
Removes the item at the start of the list and returns it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this |
The item at the start of the list
Returns the item at the start of the list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
integer, | intent(in) | :: | element | The index (starting from 1) of the element to return |
The item with index element
. Unallocated if no such element
is present.
Returns the item at the specified location in the list. Returns an unallocated container if that location has not been set.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
class(*), | intent(in) | :: | item |
Position of the first occurrence of item
in list
Returns the index of the first occurrence of the item in the list. If there are no occurrences, then returns -1.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
class(*), | intent(in) | :: | item |
Position of the last occurrence of item
in list. -1 if item
not present
Returns the index of the last occurrence of the item in the list. If there are no occurrences, then returns -1.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
class(*), | intent(in) | :: | item |
Positions of the all occurrences of item
in list. Unallocated
if item
not present.
Returns an array containing the indices of all occurrences of the item in the list. If there are no occurrences, then returns an unallocated array.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
integer, | intent(in) | :: | start_element | The index of the first element in the slice to be returned |
||
integer, | intent(in) | :: | end_element | The index of the last element in the slice to be returned |
An array_list containing the elements within the slice.
Returns an array_list instance containing all items in this list within the specified slice, inclusive. Crashes if one of the indices is outside of the list's bounds.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
class(*), | intent(in) | :: | item | A value whose presence in the list is being checked for |
.true.
if item
is present in list, .false.
otherwise
Indicates whether there are any copies of the specified item present in the list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
procedure(comparison_func) | :: | comparison | A procedure which evaluates whether a container object is less than, equal to, or greater than another |
The smallest item in the list, as determined by the
comparison
function
Returns the smallest item contained in the list, as determined using the provided comparison function.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
procedure(comparison_func) | :: | comparison | A procedure which evaluates whether a container object is less than, equal to, or greater than another |
The largest item in the list, as determined by the
comparison
function
Returns the largest item contained in the list, as determined using the provided comparison function.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
class(*), | intent(in) | :: | item | The value which those in the list are being compared to |
||
procedure(subtraction_func) | :: | subtraction | A function determining the magnitude of the difference between two items |
The value from the list which, when passed to subtraction
with item
as the other argument, returns the smallest value
Returns the value contained in the list for which the subtraction
function returns the smallest absolute real number when comparing
with the specified item
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
procedure(addition_func) | :: | addition | A procedure performing addition between two container objects and returning the result in another container |
A container holding the sum of all of the items held within this list
Returns a container representing the sum of all items contained in the list. This sum is calculated by repeatedly applying the addition procedure to the list's contents.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this | |||
procedure(test_func) | :: | test | A test for which the values that pass will be returned in a new list |
Contains those items in this list for which test
returns
.true.
Returns a new list containing only those items held in this list which pass the provided test.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(in) | :: | this |
An array of container objects holding the contents of this list
Returns copies of all items held in this list, stored within an array of container objects.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
class(*), | intent(in) | :: | item | The value to place at the start of the list. |
Adds an item to the beginning of the list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this |
Removes all items from this list, but does not change its container type.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
class(*), | intent(in) | :: | item | Item to be appended to list |
Adds the provided item to the end of the list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | element | The index (starting from 1) of the element whose value is to be set. |
||
class(*), | intent(in) | :: | item | The value to store in the specified element |
Places the value of the provided element in the specified location in the array. Crashes if this element is not already defined.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
integer, | intent(in), | dimension(:) | :: | elements | The indices (starting from 1) of the elements whose values are to be set. |
|
class(*), | intent(in), | dimension(:) | :: | items | The values to be stored in the specified elements. Each item
is placed in the element specified by the integer in the
corresponding position in the array |
Places the values of the provided array of items in the locations specified by the corresponding indices in the in the array of elements.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
procedure(action_sub) | :: | action | A procedure to act on each element of the list |
Performs the specified action on each item in the list, in place.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | position | The location at which the new element will be placed |
||
class(*), | intent(in) | :: | item | The value to be placed in the list |
Places the provided item into the list at the position specified, moving all succeeding items forward by one. The position must be one which is already filled or the length of the list plus one.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
class(*), | intent(in) | :: | item | An item, the first occurrence of which will be removed from the list |
Remove the first occurrence of the specified item from the list, moving all succeeding items back by one position. No action is taken if the item is not present.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
class(*), | intent(in) | :: | item | An item, the last occurrence of which will be removed from the list |
Remove the last occurrence of the specified item from the list, moving all succeeding items back by one position. No action is taken if the item is not present.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
class(*), | intent(in) | :: | item | An item, all occurrences of which will be removed from the list |
Remove all occurrences of the specified item from the list, moving all succeeding items back in position. No action is taken if the item is not present.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | element | The position of the element to be deleted from the list |
Removes the element at the specified position in the list, moving all succeeding items back by one position. Crashes if the element has not been set.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
integer, | intent(in), | dimension(:) | :: | element | The positions of the elements to be deleted from the list |
Removes the elements at the positions specified by the indices in
the array elements
from the list. The elements removed are those
at the specified location just before the call was made. Once all
removals have been performed, the remaining elements well be moved
backwards in position as necessary. Crashes if an element has not
been set.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | start_element | Index of the first element in the slice to be deleted |
||
integer, | intent(in) | :: | end_element | Index of the last element in the slice to be deleted |
Removes the element within the specified slice of the list, moving all succeeding items back by the number of items deleted. The slice contains the element at the start index to the end index, inclusive. Crashes if part of the slice has not been set.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(array_list), | intent(inout) | :: | this | |||
procedure(comparison_func) | :: | comparison | A procedure which evaluates whether a container object is less than, equal to, or greater than another |
Sorts the list, in place, so that all items are in ascending order according the the provided comparison function.