MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
MemoryContainerIterator.f90
Go to the documentation of this file.
2 use kindmodule, only: i4b, lgp
5
6 implicit none
7 private
8
10
11 !> @brief An iterator used to iterate through a MemoryContainer
12 !!
13 !<
15 private
16 class(iteratortype), allocatable :: container_iterator !< the current iterator to the underlying container
17 contains
18 procedure :: has_next
19 procedure :: next
20 procedure :: value
21 end type
22
24 module procedure constructor
25 end interface memorycontaineriteratortype
26
27contains
28 !> @brief Constructor to create a MemoryContainerIterator
29 !!
30 !<
31 function constructor(container_iterator) result(iterator)
32 class(iteratortype), allocatable :: container_iterator
33 type(memorycontaineriteratortype) :: iterator
34
35 call move_alloc(container_iterator, iterator%container_iterator)
36
37 end function constructor
38
39 !> @brief Indicates if there is a next node in the iteration chain
40 !!
41 !<
42 function has_next(this) result(res)
43 class(memorycontaineriteratortype) :: this
44 logical(LGP) :: res
45
46 res = this%container_iterator%has_next()
47 end function
48
49 !> @brief Increment the iterator to the next node
50 !!
51 !<
52 subroutine next(this)
53 class(memorycontaineriteratortype) :: this
54
55 call this%container_iterator%next()
56 end subroutine
57
58 !> @brief Get the value the iterator is pointing to
59 !!
60 !<
61 function value(this) result(res)
62 class(memorycontaineriteratortype), target :: this
63 type(memorytype), pointer :: res
64 ! -- local
65 class(*), pointer :: obj !< void pointer to MemoryType
66
67 obj => this%container_iterator%value()
68
69 select type (obj)
70 type is (memorytype)
71 res => obj
72 class default
73 res => null()
74 end select
75
76 end function
77
This module defines variable data types.
Definition kind.f90:8
type(memorytype) function, pointer value(this)
Get the value the iterator is pointing to.
subroutine next(this)
Increment the iterator to the next node.
logical(lgp) function has_next(this)
Indicates if there is a next node in the iteration chain.
type(memorycontaineriteratortype) function constructor(container_iterator)
Constructor to create a MemoryContainerIterator.
An iterator used to iterate through a MemoryContainer.