data_set Derived Type

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

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


An abstract type for set data structures. These sets support a similar selection of operations as do their mathematical counterparts. The collection of methods for this type waas inspired by those available for the frozenset type in Python.

Inherited By

type~~data_set~~InheritedByGraph type~data_set data_set type~dictionary dictionary type~data_set->type~dictionary type~dynamic_set dynamic_set type~data_set->type~dynamic_set type~map map type~dictionary->type~map type~multimap multimap type~dictionary->type~multimap type~multiset multiset type~dynamic_set->type~multiset
Help

Type-Bound Procedures

procedure(union_func), public, deferred :: union

Returns a set containing the items held in this set and the passed set.

  • pure function union_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value class(data_set), allocatable

    A set containing all elements found in this one and the other

generic, public :: operator(+) => union

Returns the union of the two sets

  • pure function union_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value class(data_set), allocatable

    A set containing all elements found in this one and the other

procedure(intersect_func), public, deferred :: intersection

Returns a set containing only the items present in both this set and the argument

  • pure function intersect_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value integer

procedure(diff_func), public, deferred :: difference

Returns a set containing the item present in this set but not present in the argument

  • pure function diff_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value class(data_set), allocatable

    A set containing elements found in this one and not the other

generic, public :: operator(-) => difference

Returns the difference between the two sets

  • pure function diff_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value class(data_set), allocatable

    A set containing elements found in this one and not the other

procedure(pure_diff_func), public, deferred :: symmetric_difference

Returns a set containing those items present either only in this set or only in the argument

  • pure function pure_diff_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value class(data_set), allocatable

    A set containing elements found in one, but not both, of this set or the other set

procedure(relation_func), public, deferred :: is_disjoint

True if none of the items in this set are present in the argument

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

procedure(relation_func), public, deferred :: is_subset

True if every element in this set is also in the argument

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

procedure(relation_func), public, deferred :: is_proper_subset

True if every element in this set is also in the argument and this set is not equal to the argument

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

procedure(relation_func), public, deferred :: is_superset

True if every element in the argument is also present in this set.

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

procedure(relation_func), public, deferred :: is_proper_superset

True if every element in the argument is also present in this set and the argument is not equal to this set.

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

procedure(relation_func), public, deferred :: is_equal

True if this set and the argument contain only the same items.

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

generic, public :: operator(<=) => is_subset

True if every element in this set is also in the argument

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

generic, public :: operator(<) => is_proper_subset

True if every element in this set is also in the argument and this set is not equal to the argument

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

generic, public :: operator(>=) => is_superset

True if every element in the argument is also present in this set.

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

generic, public :: operator(>) => is_proper_superset

True if every element in the argument is also present in this set and the argument is not equal to this set.

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

generic, public :: operator(==) => is_equal

True if this set and the argument contain only the same items.

  • pure function relation_func(this, other) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    class(data_set), intent(in) :: other

    A second set

    Return Value logical

    Whether the relationship between this and other is true

procedure(has_func), public, deferred :: has

True if the argument is present in the set

  • pure function has_func(this, item) Prototype

    Arguments

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

    An item which may be contained in the set

    Return Value logical

    Whether item is present in this set

procedure(empty_func), public, deferred :: is_empty

True if the set contains no items

  • pure function empty_func(this) Prototype

    Arguments

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

    Return Value logical

    .true. if this set contains no items

procedure(peek_func), public, deferred :: peek

Returns an item, at random, from the set

  • pure function peek_func(this) Prototype

    Arguments

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

    Return Value class(container), allocatable

    An item contained within the set. Is unallocated if the set is empty.

procedure(filter_func), public, deferred :: filter

Returns a set containing all elements from this set for which the provided test procedure returns .true.

  • pure function filter_func(this, test) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    procedure(test_func) :: test

    A test for which the values that pass will be returned in a new list

    Return Value class(data_set), allocatable

    Contains those items in this set for which test returns .true.

procedure(enum_func), public, deferred :: enumerate

Returns an [array_list] containing all of the items present in this set.

  • pure function enum_func(this) Prototype

    Arguments

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

    Return Value type(array_list)

    A list containing copies of all of the items in this set

procedure(min_func), public, deferred :: min

Returns the smallest item in the set as determined using the provided comparison procedure

  • pure function min_func(this, comparison) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    procedure(comparison_func) :: comparison

    A procedure which evaluates whether a container object is less than, equal to, or greater than another

    Return Value class(container), allocatable

    The smallest item in the set, as determined by the comparison function

procedure(max_func), public, deferred :: max

Returns the largest item in the set as determined using the provided comparison procedure

  • pure function max_func(this, comparison) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    procedure(comparison_func) :: comparison

    A procedure which evaluates whether a container object is less than, equal to, or greater than another

    Return Value class(container), allocatable

    The largest item in the set, as determined by the comparison function

procedure(nearest_func), public, deferred :: nearest

Returns the item in the set for which the provided subtraction procedure returns the smallest absolute value

  • pure function nearest_func(this, item, subtraction) Prototype

    Arguments

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

    The value which those in the set are being compared to

    procedure(subtraction_func) :: subtraction

    A function determining the magnitude of the difference between two items

    Return Value class(container), allocatable

    The value from the set which, when passed to subtraction with item as the other argument, returns the smallest value

procedure(sum_func), public, deferred :: sum

Returns an item representing the sum as determined by iteratively applying the provided addition procedure to all items in the set

  • pure function sum_func(this, addition) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(data_set), intent(in) :: this
    procedure(addition_func) :: addition

    A procedure performing addition between two container objects and returning the result in another container

    Return Value class(container), allocatable

    A container holding the sum of all of the items held within this set

Source Code

  type, public, extends(countable), abstract :: data_set
    !* Author: Chris MacMackin
    !  Date: March 2016
    !
    ! An abstract type for set data structures. These sets support a 
    ! similar selection of operations as do their mathematical
    ! counterparts. The collection of methods for this type waas inspired
    ! by those available for the
    ! [frozenset](https://docs.python.org/2/library/stdtypes.html#frozenset)
    ! type in Python.
    !
  contains
    procedure(union_func), deferred :: union
      !! Returns a set containing the items held in this set and the
      !! passed set.
    generic :: operator(+) => union
      !! Returns the union of the two sets
    procedure(intersect_func), deferred :: intersection
      !! Returns a set containing only the items present in both this
      !! set and the argument
    procedure(diff_func), deferred :: difference
      !! Returns a set containing the item present in this set but not
      !! present in the argument
    generic :: operator(-) => difference
        !! Returns the difference between the two sets
    procedure(pure_diff_func), deferred :: symmetric_difference
      !! Returns a set containing those items present either only in 
      !! this set or only in the argument
    procedure(relation_func), deferred :: is_disjoint
      !! True if none of the items in this set are present in the 
      !! argument
    procedure(relation_func), deferred :: is_subset
      !! True if every element in this set is also in the argument
    procedure(relation_func), deferred :: is_proper_subset
      !! True if every element in this set is also in the argument and
      !! this set is not equal to the argument
    procedure(relation_func), deferred :: is_superset
      !! True if every element in the argument is also present in this
      !! set.
    procedure(relation_func), deferred :: is_proper_superset
      !! True if every element in the argument is also present in this
      !! set and the argument is not equal to this set.
    procedure(relation_func), deferred :: is_equal
      !! True if this set and the argument contain only the same items.
    generic :: operator(<=) => is_subset
      !! True if every element in this set is also in the argument
    generic :: operator(<) => is_proper_subset
      !! True if every element in this set is also in the argument and
      !! this set is not equal to the argument
    generic :: operator(>=) => is_superset
      !! True if every element in the argument is also present in this
      !! set.
    generic :: operator(>) => is_proper_superset
      !! True if every element in the argument is also present in this
      !! set and the argument is not equal to this set.
    generic :: operator(==) => is_equal
      !! True if this set and the argument contain only the same items.
    procedure(has_func), deferred :: has
      !! True if the argument is present in the set
    procedure(empty_func), deferred :: is_empty
      !! True if the set contains no items
    procedure(peek_func), deferred :: peek
      !! Returns an item, at random, from the set
    procedure(filter_func), deferred :: filter
      !! Returns a set containing all elements from this set for which
      !! the provided test procedure returns `.true.`
    procedure(enum_func), deferred :: enumerate
      !! Returns an [array_list] containing all of the items present
      !! in this set.
    procedure(min_func), deferred :: min
      !! Returns the smallest item in the set as determined using the
      !! provided comparison procedure
    procedure(max_func), deferred :: max
      !! Returns the largest item in the set as determined using the
      !! provided comparison procedure
    procedure(nearest_func), deferred :: nearest
      !! Returns the item in the set for which the provided subtraction
      !! procedure returns the smallest absolute value
    procedure(sum_func), deferred :: sum
      !! Returns an item representing the sum as determined by
      !! iteratively applying the provided addition procedure to all
      !! items in the set
  end type data_set