ordered Derived Type

type, public, abstract, extends(countable) :: ordered

type~~ordered~~InheritsGraph type~ordered ordered type~countable countable type~countable->type~ordered type~iterable iterable type~iterable->type~countable
Help


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.

Inherited By

type~~ordered~~InheritedByGraph type~ordered ordered type~queue queue type~ordered->type~queue type~deque deque type~queue->type~deque type~list list type~deque->type~list type~array_list array_list type~list->type~array_list
Help

Type-Bound Procedures

procedure(push_sub), public, deferred :: push

Place a new item in the data structure

  • pure subroutine push_sub(this, item) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(inout) :: this
    class(*), intent(in) :: item

    Contents to be added to this data structure

procedure(pop_func), public, deferred :: pop

Remove and return the next item from the data structure

  • function pop_func(this) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(inout) :: this

    Return Value class(container), allocatable

    The next item in the data structure, which has been removed

procedure(peek_func), public, deferred :: peek

Return, but do not remove, the next item in the data structure

  • pure function peek_func(this) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(in) :: this

    Return Value class(container), allocatable

    The next item in the data structure

procedure(blank_sub), public, deferred :: clear

Remove all contents from the data structure

  • pure subroutine blank_sub(this) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(inout) :: this

procedure(logical_return), public, nopass, deferred :: is_fifo

Indicates whether this is a first in first out or last in last out data type.

  • pure function logical_return() Prototype

    Arguments

    None

    Return Value logical

    True if first in first out structure, false if last in first out

procedure, private :: array_extend

Add (push) the elements of an array to this data structure

  • private subroutine array_extend(this, items)

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(inout) :: this
    class(*), intent(in), dimension(:):: items

    The items to be added to this data structure

    Description

    Author
    Chris MacMackin
    Date
    February 2016

    Adds the elements of an array to this object.

procedure, private :: iterator_extend

Add ([[ordered::push]]) the contents of an iterator to this data structure.

  • private subroutine iterator_extend(this, items)

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(inout) :: this
    class(iterable), intent(inout) :: items

    The iterable whose contents are to be added to this data structure.

    Description

    Author
    Chris MacMackin
    Date
    February 2016

    Adds the contents of an iterable object to this data structure.

generic, public :: extend => array_extend, iterator_extend

Place multiple new items in the data structure

  • private subroutine array_extend(this, items)

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(inout) :: this
    class(*), intent(in), dimension(:):: items

    The items to be added to this data structure

    Description

    Author
    Chris MacMackin
    Date
    February 2016

    Adds the elements of an array to this object.

  • private subroutine iterator_extend(this, items)

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(inout) :: this
    class(iterable), intent(inout) :: items

    The iterable whose contents are to be added to this data structure.

    Description

    Author
    Chris MacMackin
    Date
    February 2016

    Adds the contents of an iterable object to this 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 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.

  • pure function concat_func(lhs, rhs) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(in) :: lhs

    This object

    class(ordered), intent(in) :: rhs

    The object being concatenated to this one

    Return Value class(ordered), allocatable

    The result of the concatenation

generic, public :: 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 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.

  • pure function concat_func(lhs, rhs) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(ordered), intent(in) :: lhs

    This object

    class(ordered), intent(in) :: rhs

    The object being concatenated to this one

    Return Value class(ordered), allocatable

    The result of the concatenation

Source Code

  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