dynamic_set Derived Type

type, public, abstract, extends(data_set) :: dynamic_set

type~~dynamic_set~~InheritsGraph type~dynamic_set dynamic_set type~data_set data_set type~data_set->type~dynamic_set type~countable countable type~countable->type~data_set type~iterable iterable type~iterable->type~countable
Help


An abstract data type for dynamic sets. These are much like mathematical sets, but differ from the parent data_set type in that items can be added to or removed from the set. To accomplish this, various additional methods are available. This data type is similar to the set type in Python.

Inherited By

type~~dynamic_set~~InheritedByGraph type~dynamic_set dynamic_set type~multiset multiset type~dynamic_set->type~multiset
Help

Type-Bound Procedures

procedure(single_sub), private, deferred :: add_single

Places the item in the set, if not already present

  • pure subroutine single_sub(this, item) Prototype

    Arguments

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

    An item to add or remove from the set

procedure(multiple_sub), private, deferred :: add_multiple

Places each item in the array into the set, if not already present

  • pure subroutine multiple_sub(this, items) Prototype

    Arguments

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

    An array containing items to add or remove from the set

generic, public :: add => add_single, add_multiple

  • pure subroutine single_sub(this, item) Prototype

    Arguments

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

    An item to add or remove from the set

  • pure subroutine multiple_sub(this, items) Prototype

    Arguments

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

    An array containing items to add or remove from the set

procedure(iter_sub), public, deferred :: add_iter

Places each item in the iterable into the set, if not already present.

  • pure subroutine iter_sub(this, items) Prototype

    Arguments

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

    An iterable containing items to add or remove from the set

procedure(single_sub), private, deferred :: remove_single

Removes the item from the set, if present

  • pure subroutine single_sub(this, item) Prototype

    Arguments

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

    An item to add or remove from the set

procedure(multiple_sub), private, deferred :: remove_multiple

Removes each item in the array from the set, if present

  • pure subroutine multiple_sub(this, items) Prototype

    Arguments

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

    An array containing items to add or remove from the set

generic, public :: remove => remove_single, remove_multiple

  • pure subroutine single_sub(this, item) Prototype

    Arguments

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

    An item to add or remove from the set

  • pure subroutine multiple_sub(this, items) Prototype

    Arguments

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

    An array containing items to add or remove from the set

procedure(iter_sub), public, deferred :: remove_iter

Removes each item in the iterable from the set, if present

  • pure subroutine iter_sub(this, items) Prototype

    Arguments

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

    An iterable containing items to add or remove from the set

procedure(pop_func), public, deferred :: pop

Removes a random item from the set and returns it

  • function pop_func(this) Prototype

    Arguments

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

    Return Value class(container), allocatable

    A random item which has been removed from the set

procedure(clear_sub), public, deferred :: clear

Removes all items from the set

  • pure subroutine clear_sub(this) Prototype

    Arguments

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

Source Code

  type, public, abstract, extends(data_set) :: dynamic_set
    !* Author: Chris MacMackin
    !  Date: March 2016
    !
    ! An abstract data type for dynamic sets. These are much like
    ! mathematical sets, but differ from the parent [[data_set]] type
    ! in that items can be added to or removed from the set. To
    ! accomplish this, various additional methods are available. This
    ! data type is similar to the 
    ! [set](https://docs.python.org/2/library/stdtypes.html#set) type in
    ! Python.
    !
  contains
    procedure(single_sub), deferred, private :: add_single
      !! Places the item in the set, if not already present
    procedure(multiple_sub), deferred, private :: add_multiple
      !! Places each item in the array into the set, if not already 
      !! present
    generic :: add => add_single, add_multiple
    procedure(iter_sub), deferred :: add_iter
      !! Places each item in the iterable into the set, if not already
      !! present.
    procedure(single_sub), deferred, private :: remove_single
      !! Removes the item from the set, if present
    procedure(multiple_sub), deferred, private :: remove_multiple
      !! Removes each item in the array from the set, if present
    generic :: remove => remove_single, remove_multiple
    procedure(iter_sub), deferred :: remove_iter
      !! Removes each item in the iterable from the set, if present
    procedure(pop_func), deferred :: pop
      !! Removes a random item from the set and returns it
    procedure(clear_sub), deferred :: clear
      !! Removes all items from the set
  end type dynamic_set