deque Derived Type

type, public, abstract, extends(queue) :: deque

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


An abstract data type representing the double ended queue data structure. Rather than just pushing items to one end (the "left end") and popping them from the other (the "right end"), items can be pushed or popped to/from either the right or the left.

Inherited By

type~~deque~~InheritedByGraph type~deque 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 :: pushleft

Add an item to the left end of the data structure (equivalent to push on a queue)

  • pure subroutine push_sub(this, item) Prototype

    Arguments

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

    The value to be added to the list

procedure(push_sub), public, deferred :: pushright

Add an item to the right end of the data structure

  • pure subroutine push_sub(this, item) Prototype

    Arguments

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

    The value to be added to the list

procedure(pop_func), public, deferred :: popleft

Remove and return the item from the left end of the data structure

  • function pop_func(this) Prototype

    Arguments

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

    Return Value class(container), allocatable

    The next value, which has just been removed

procedure(pop_func), public, deferred :: popright

Remove and return the item from the right end of the data structure (equivalent to pop on a queue)

  • function pop_func(this) Prototype

    Arguments

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

    Return Value class(container), allocatable

    The next value, which has just been removed

procedure(peek_func), public, deferred :: peekleft

Return, but do not remove, the item at the left end of the data structure

  • pure function peek_func(this) Prototype

    Arguments

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

    Return Value class(container), allocatable

    The next value, which is not removed

procedure(peek_func), public, deferred :: peekright

Return, but do not remove, the item at the left end of the data structure (equivalent to peek on a queue)

  • pure function peek_func(this) Prototype

    Arguments

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

    Return Value class(container), allocatable

    The next value, which is not removed

Source Code

  type, abstract, extends(queue), public :: deque
  !* Author: Chris MacMackin
  !  Date: March 2016
  !
  ! An abstract data type representing the double ended queue data
  ! structure. Rather than just pushing items to one end (the "left 
  ! end") and popping them from the other (the "right end"), items can
  ! be pushed or popped to/from either the right or the left.
  !
  contains
    procedure(push_sub), deferred :: pushleft
      !! Add an item to the left end of the data structure (equivalent
      !! to [[ordered:push]] on a queue)
    procedure(push_sub), deferred :: pushright
      !! Add an item to the right end of the data structure
    procedure(pop_func), deferred :: popleft
      !! Remove and return the item from the left end of the data
      !! structure
    procedure(pop_func), deferred :: popright
      !! Remove and return the item from the right end of the data
      !! structure (equivalent to [[ordered:pop]] on a queue)
    procedure(peek_func), deferred :: peekleft
      !! Return, but do not remove, the item at the left end of the data
      !! structure
    procedure(peek_func), deferred :: peekright
      !! Return, but do not remove, the item at the left end of the data
      !! structure (equivalent to [[ordered:peek]] on a queue)
  end type deque