An abstract type which is an ancestor for any data structure in which items are stored in a particular order. This means that the order in which items are placed in the structure will determine the order in which they are retrieved. Examples of data structures descending from this one are a [[stack]], queue, or list.
Place a new item in the data structure
Remove and return the next item from the data structure
Return, but do not remove, the next item in the data structure
Remove all contents from the data structure
Indicates whether this is a first in first out or last in last out data type.
True if first in first out structure, false if last in first out
Add (push) the elements of an array to this data structure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ordered), | intent(inout) | :: | this | |||
class(*), | intent(in), | dimension(:) | :: | items | The items to be added to this data structure |
Adds the elements of an array to this object.
Add ([[ordered::push]]) the contents of an iterator to this data structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ordered), | intent(inout) | :: | this | |||
class(iterable), | intent(inout) | :: | items | The iterable whose contents are to be added to this data structure. |
Adds the contents of an iterable object to this data structure.
Place multiple new items in the data structure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ordered), | intent(inout) | :: | this | |||
class(*), | intent(in), | dimension(:) | :: | items | The items to be added to this data structure |
Adds the elements of an array to this object.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ordered), | intent(inout) | :: | this | |||
class(iterable), | intent(inout) | :: | items | The iterable whose contents are to be added to this data structure. |
Adds the contents of an iterable object to this data structure.
Join this object with another ordered object, returning the result. The contents of the returned object are ordered such that applying pop until the structure is empty would provide items in the same order as calling pop until the first object is empty and then until the second object is empty.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ordered), | intent(in) | :: | lhs | This object |
||
class(ordered), | intent(in) | :: | rhs | The object being concatenated to this one |
The result of the concatenation
Overloads the concatenation operator to join this object with another ordered object, returning the result. The contents of the returned object are ordered such that applying pop until the structure is empty would provide items in the same order as calling pop until the first object is empty and then until the second object is empty.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ordered), | intent(in) | :: | lhs | This object |
||
class(ordered), | intent(in) | :: | rhs | The object being concatenated to this one |
The result of the concatenation
type, extends(countable), abstract, public :: ordered
!* Author: Chris MacMackin
! Date: February 2016
!
! An abstract type which is an ancestor for any data structure in
! which items are stored in a particular order. This means that
! the order in which items are placed in the structure will
! determine the order in which they are retrieved. Examples of data
! structures descending from this one are a [[stack]], [[queue]], or
! [[list]].
!
contains
procedure(push_sub), deferred :: push
!! Place a new item in the data structure
procedure(pop_func), deferred :: pop
!! Remove and return the next item from the data structure
procedure(peek_func), deferred :: peek
!! Return, but do not remove, the next item in the data structure
procedure(blank_sub), deferred :: clear
!! Remove all contents from the data structure
procedure(logical_return), nopass, deferred :: is_fifo
!! Indicates whether this is a first in first out or last in last
!! out data type.
procedure, private :: array_extend
!! Add ([[ordered:push]]) the elements of an array to this data
!! structure
procedure, private :: iterator_extend
!! Add ([[ordered::push]]) the contents of an [[iterator]] to
!! this data structure.
generic :: extend => array_extend, iterator_extend
!! Place multiple new items in the data structure
procedure(concat_func), private, deferred :: concat
!! Join this object with another [[ordered]] object, returning
!! the result. The contents of the returned object are ordered
!! such that applying [[ordered:pop]] until the structure is
!! empty would provide items in the same order as calling
!! [[ordered:pop]] until the first object is empty and then until
!! the second object is empty.
generic :: operator(//) => concat
!! Overloads the concatenation operator to join this object with
!! another [[ordered]] object, returning the result. The contents
!! of the returned object are ordered such that applying
!! [[ordered:pop]] until the structure is empty would provide
!! items in the same order as calling [[ordered:pop]] until the
!! first object is empty and then until the second object is
!! empty.
end type ordered