Skip to content

mod_set_real

Lines: 161 | Visibility: public

Ordered set with unique entries author: Moritz R. Schaefer

Dependencies

Uses

module~~mod_set_real~~UsesGraph module~mod_set_real mod_set_real module~mod_precision mod_precision module~mod_set_real->module~mod_precision module~mod_throw mod_throw module~mod_set_real->module~mod_throw iso_c_binding iso_c_binding module~mod_precision->iso_c_binding iso_fortran_env iso_fortran_env module~mod_precision->iso_fortran_env module~mod_throw->module~mod_precision module~mod_throw->iso_c_binding module~mod_throw->iso_fortran_env module~mod_io mod_io module~mod_throw->module~mod_io module~mod_mpi mod_mpi module~mod_throw->module~mod_mpi module~mod_sort mod_sort module~mod_throw->module~mod_sort module~mod_io->module~mod_precision module~mod_io->iso_fortran_env module~mod_optional_args mod_optional_args module~mod_io->module~mod_optional_args module~mod_mpi->module~mod_precision mpi_f08 mpi_f08 module~mod_mpi->mpi_f08 module~mod_sort->module~mod_precision

Derived Types Summary

Name Description
SetReal A set of real numbers This type represents a set of reals. The elements are stored in an...

Procedures Summary

Name Type Description
constructor_empty Function Create an empty SetReal ready to store elements.
constructor_from_elements Function Create a set from a list of elements The elements will be added to the set in the order they are given
constructor_from_element Function Create a set from a one element
constructor_from_sets Function Create a set from a list of sets
contains Function Check if an element is in the set Returns .true. if the element is in the set, .false. otherwise
get_elements Function Get all elements of the set
get_size Function Get the number of elements in the set
intersect Function Get the intersection of two sets The intersection of two sets is the set of elements that are...
union Function Get the union of two sets The union of two sets is the set of elements that are in either set
difference Function Get the difference of two sets The difference of two sets is the set of elements that are in...
symmetric_difference Function Get the symmetric difference of two sets The symmetric difference of two sets is the set of...
is_subset Function Check if a another set is a subset of this set
is_superset Function Check if a another set is a superset of this set
get_index_in_set Function Get the index of an element in the set Returns -1 if the element is not in the set
get_element_by_index Function Get the element at a specific index Throws an error if the index is out of range
add_element Subroutine Add an element to the set If the element is already in the set, it will not be added again
add_elements Subroutine Add multiple elements to the set If an element is already in the set, it will not be added again
remove Subroutine Remove an element from the set If the element is not in the set, nothing will be done

Derived Types Details

type SetReal

A set of real numbers

This type represents a set of reals. The elements are stored in an array and are unique. The order of the elements is preserved.

Components

  • elements : real(DP)– The elements of the set
  • size : integer– The number of elements in the set

Type-Bound Procedures

Name Attributes Binding
remove public ⇒ remove
contains public ⇒ contains
get_size public ⇒ get_size
get_elements public ⇒ get_elements
intersect public ⇒ intersect
union public ⇒ union
difference public ⇒ difference
symmetric_difference public ⇒ symmetric_difference
is_subset public ⇒ is_subset
is_superset public ⇒ is_superset
get_element_by_index public ⇒ get_element_by_index
get_index_in_set public ⇒ get_index_in_set
add public ⇒ add_element⇒ add_elements
add_element private ⇒ add_element
add_elements private ⇒ add_elements

Interface Details

interface SetReal


Procedure Details

function constructor_empty

function constructor_empty()

Create an empty SetReal ready to store elements.

Called By

proc~~constructor_empty~4~~CalledByGraph proc~constructor_empty~4 mod_set_real::constructor_empty interface~setreal mod_set_real::SetReal interface~setreal->proc~constructor_empty~4

function constructor_from_elements

function constructor_from_elements( &
    elements &
)

Create a set from a list of elements

The elements will be added to the set in the order they are given

Arguments

  • elements : real(DP) [in]

Called By

proc~~constructor_from_elements~3~~CalledByGraph proc~constructor_from_elements~3 mod_set_real::constructor_from_elements interface~setreal mod_set_real::SetReal interface~setreal->proc~constructor_from_elements~3

function constructor_from_element

function constructor_from_element( &
    element &
)

Create a set from a one element

Arguments

  • element : real(DP) [in]

Called By

proc~~constructor_from_element~3~~CalledByGraph proc~constructor_from_element~3 mod_set_real::constructor_from_element interface~setreal mod_set_real::SetReal interface~setreal->proc~constructor_from_element~3

function constructor_from_sets

function constructor_from_sets( &
    sets &
)

Create a set from a list of sets

Arguments

Called By

proc~~constructor_from_sets~2~~CalledByGraph proc~constructor_from_sets~2 mod_set_real::constructor_from_sets interface~setreal mod_set_real::SetReal interface~setreal->proc~constructor_from_sets~2

function contains

function contains( &
    self, &
    element &
)

Check if an element is in the set

Returns .true. if the element is in the set, .false. otherwise

Arguments

  • self : class(SetReal) [in]
  • element : real(DP) [in]

function get_elements

function get_elements( &
    self &
)

Get all elements of the set

Arguments

Called By

proc~~get_elements~3~~CalledByGraph proc~get_elements~3 mod_set_real::SetReal%get_elements proc~constructor_from_sets~2 mod_set_real::constructor_from_sets proc~constructor_from_sets~2->proc~get_elements~3 proc~intersect~3 mod_set_real::SetReal%intersect proc~intersect~3->proc~get_elements~3 proc~is_subset~3 mod_set_real::SetReal%is_subset proc~is_subset~3->proc~get_elements~3 proc~union~3 mod_set_real::SetReal%union proc~union~3->proc~get_elements~3 interface~setreal mod_set_real::SetReal interface~setreal->proc~constructor_from_sets~2 proc~is_superset~3 mod_set_real::SetReal%is_superset proc~is_superset~3->proc~is_subset~3 proc~symmetric_difference~3 mod_set_real::SetReal%symmetric_difference proc~symmetric_difference~3->proc~union~3

function get_size

function get_size( &
    self &
)

Get the number of elements in the set

Arguments


function intersect

function intersect( &
    self, &
    other &
)

Get the intersection of two sets

The intersection of two sets is the set of elements that are in both sets

Arguments


function union

function union( &
    self, &
    other &
)

Get the union of two sets

The union of two sets is the set of elements that are in either set

Arguments

Called By

proc~~union~3~~CalledByGraph proc~union~3 mod_set_real::SetReal%union proc~symmetric_difference~3 mod_set_real::SetReal%symmetric_difference proc~symmetric_difference~3->proc~union~3

function difference

function difference( &
    self, &
    other &
)

Get the difference of two sets

The difference of two sets is the set of elements that are in the first set but not in the second set

Arguments

Called By

proc~~difference~3~~CalledByGraph proc~difference~3 mod_set_real::SetReal%difference proc~symmetric_difference~3 mod_set_real::SetReal%symmetric_difference proc~symmetric_difference~3->proc~difference~3

function symmetric_difference

function symmetric_difference( &
    self, &
    other &
)

Get the symmetric difference of two sets

The symmetric difference of two sets is the set of elements that are in either set but not in both sets

Arguments


function is_subset

function is_subset( &
    self, &
    other &
)

Check if a another set is a subset of this set

Arguments

Called By

proc~~is_subset~3~~CalledByGraph proc~is_subset~3 mod_set_real::SetReal%is_subset proc~is_superset~3 mod_set_real::SetReal%is_superset proc~is_superset~3->proc~is_subset~3

function is_superset

function is_superset( &
    self, &
    other &
)

Check if a another set is a superset of this set

Arguments


function get_index_in_set

function get_index_in_set( &
    self, &
    element &
)

Get the index of an element in the set

Returns -1 if the element is not in the set

Arguments

  • self : class(SetReal) [in]
  • element : real(DP) [in]

function get_element_by_index

function get_element_by_index( &
    self, &
    index &
)

Get the element at a specific index

Throws an error if the index is out of range

Arguments

  • self : class(SetReal) [in]
  • index : integer [in]

subroutine add_element

subroutine add_element( &
    self, &
    element &
)

Add an element to the set

If the element is already in the set, it will not be added again

Arguments

  • self : class(SetReal) [inout]
  • element : real(DP) [in]

Called By

proc~~add_element~3~~CalledByGraph proc~add_element~3 mod_set_real::SetReal%add_element none~add~3 mod_set_real::SetReal%add none~add~3->proc~add_element~3 proc~add_elements~3 mod_set_real::SetReal%add_elements none~add~3->proc~add_elements~3 proc~add_elements~3->proc~add_element~3 proc~constructor_from_elements~3 mod_set_real::constructor_from_elements proc~constructor_from_elements~3->none~add~3 proc~constructor_from_element~3 mod_set_real::constructor_from_element proc~constructor_from_element~3->none~add~3 proc~constructor_from_sets~2 mod_set_real::constructor_from_sets proc~constructor_from_sets~2->none~add~3 interface~setreal mod_set_real::SetReal interface~setreal->proc~constructor_from_elements~3 interface~setreal->proc~constructor_from_element~3 interface~setreal->proc~constructor_from_sets~2

subroutine add_elements

subroutine add_elements( &
    self, &
    elements &
)

Add multiple elements to the set

If an element is already in the set, it will not be added again

Arguments

  • self : class(SetReal) [inout]
  • elements : real(DP) [in]

Called By

proc~~add_elements~3~~CalledByGraph proc~add_elements~3 mod_set_real::SetReal%add_elements none~add~3 mod_set_real::SetReal%add none~add~3->proc~add_elements~3 proc~constructor_from_elements~3 mod_set_real::constructor_from_elements proc~constructor_from_elements~3->none~add~3 proc~constructor_from_element~3 mod_set_real::constructor_from_element proc~constructor_from_element~3->none~add~3 proc~constructor_from_sets~2 mod_set_real::constructor_from_sets proc~constructor_from_sets~2->none~add~3 interface~setreal mod_set_real::SetReal interface~setreal->proc~constructor_from_elements~3 interface~setreal->proc~constructor_from_element~3 interface~setreal->proc~constructor_from_sets~2

subroutine remove

subroutine remove( &
    self, &
    element &
)

Remove an element from the set

If the element is not in the set, nothing will be done

Arguments

  • self : class(SetReal) [inout]
  • element : real(DP) [in]