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.
Places the item in the set, if not already present
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(*), | intent(in) | :: | item | An item to add or remove from the set |
Places each item in the array into the set, if not already present
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(*), | intent(in), | dimension(:) | :: | items | An array containing items to add or remove from the set |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(*), | intent(in) | :: | item | An item to add or remove from the set |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(*), | intent(in), | dimension(:) | :: | items | An array containing items to add or remove from the set |
Places each item in the iterable into the set, if not already present.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(iterable), | intent(in) | :: | items | An iterable containing items to add or remove from the set |
Removes the item from the set, if present
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(*), | intent(in) | :: | item | An item to add or remove from the set |
Removes each item in the array from the set, if present
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(*), | intent(in), | dimension(:) | :: | items | An array containing items to add or remove from the set |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(*), | intent(in) | :: | item | An item to add or remove from the set |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(*), | intent(in), | dimension(:) | :: | items | An array containing items to add or remove from the set |
Removes each item in the iterable from the set, if present
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this | |||
| class(iterable), | intent(in) | :: | items | An iterable containing items to add or remove from the set |
Removes a random item from the set and returns it
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this |
A random item which has been removed from the set
Removes all items from the set
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dynamic_set), | intent(inout) | :: | this |
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