Provides an abstract container derived type which can be used as a sort of unlimited polymorphic entity whose contents are retrievable with type-guards. Different subclasses are created in order to hold different data-types. See container for instructions on creating concrete subclasses. See container_mod for subclasses containing the built-in data-types.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(container), | intent(inout) | :: | item | A container object which is will be modified in some way |
An abstract interface for a procedure which will act on each item in a list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(container), | intent(in) | :: | item | The item which is being evaluated |
Whether the item passes the test or not
An abstract interface for a function which tests a container object in some way
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(container), | intent(in) | :: | item1 | One of the items in the addition |
||
class(container), | intent(in) | :: | item2 | The other item in the addition |
The sum, item1 + item2
Performs an addition operation on two container objects, returning the result in a container.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(container), | intent(in) | :: | item1 | The item which the other is subtracted from |
||
class(container), | intent(in) | :: | item2 | The item subtracted from the other |
A real number, the absolute value of which represents the
magnitude of the difference between item1
and item2
.
An abstract interface for a procedure finding the difference
between two items, item1 - item2
. Note that a procedure may
satisfy both this abstract interface and comparison_func.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(container), | intent(in) | :: | item1 | The first item in the comparison |
||
class(container), | intent(in) | :: | item2 | The second item in the comparison |
negative if item1 < item2
, 0 if item1 == item2
, positive
if item1 > item2
An abstract interface for a procedure comparing two container objects. Note that a procedure may satisfy both this abstract interface and subtraction_func.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=i1), | private, | dimension(:), allocatable | :: | storage | Variable in which to place data contents |
||
logical, | private | :: | filled | = | .false. |
|
procedure(guard), private, deferred :: typeguard | Performs the actual transfer of the container's contents to another variable. |
procedure, public :: contents | Retrieves the contents of the container, in the form of an integer array. |
procedure, public :: is_filled | Returns whether contents have been assigned to the container |
procedure, public :: set | Sets the contents of the container. |
procedure, private, pass(rhs) :: assign_container | Assigns container contents to another variable. |
procedure, private :: is_equal | Check whether two containers have the same contents. |
generic, public :: assignment(=) => assign_container | |
generic, public :: operator(==) => is_equal |
An abstract derived type which contains data. This type can be
used for a sort of unlimited polymorphism. It is extended to
create different classes capable of holding particular
data-types. Extensions must implement the procedure
typeguard in order to provide the ability to
transfer data out of the container and into a variable. Assuming
that you are creating a concrete class called
example_container
, this should be implemented as follows:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(container), | intent(in) | :: | this |
Returns the contents, encoded as a character array, of the container.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(container), | intent(in) | :: | this |
Returns .true.
if a value has been assigned to the container,
.false.
otherwise.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(inout) | :: | lhs | The variable which the container contents will be assigned to. |
||
class(container), | intent(in) | :: | rhs | The container variable. |
Transfers the contents of the container to another variable.
If the other variable is another container of the same type
then the contents will be transferred. If the other variable is
the same type as the contents of the container (as determined
by the typeguard routine provided for that
concrete type extension) then it will be given the value held by
the container. Otherwise, an error message will be printed and
the program stopped. If compiled with gfortran
then a backtrace
will also be printed. In the event that the container was never
set to a value, then this also constitutes an error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(container), | intent(out) | :: | this | |||
class(*), | intent(in) | :: | content | The value to be placed in the container |
Sets the contents of the storage array to value passed. The type
of the variable provided must be the same as the container
variable is designed to accept (as determined by the
concrete type implementation of the typeguard
method in the extension) or be of the same type of container.
Otherwise an error message will be printed and the program will
exit. If gfortran
was used to compile then a backtrace will
also be printed.