MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
ptrhashtableiteratormodule Module Reference

Data Types

interface  ptrhashtableiteratortype
 An iterator used to iterate through a PtrHashTable. More...
 

Functions/Subroutines

type(ptrhashtableiteratortype) function constructor (buckets)
 Constructor to create a PtrHashTableIterator. More...
 
type(logical) function has_next (this)
 Indicates if there is a next node in the iteration chain. More...
 
subroutine next (this)
 Increment the iterator to the next node. More...
 
class(*) function, pointer value (this)
 Get the value the iterator is pointing to. More...
 

Function/Subroutine Documentation

◆ constructor()

type(ptrhashtableiteratortype) function ptrhashtableiteratormodule::constructor ( type(keyvaluelisttype), dimension(:), intent(in), target  buckets)
private

Definition at line 32 of file PtrHashTableIterator.f90.

33  type(KeyValueListType), target, dimension(:), intent(in) :: buckets
34  type(PtrHashTableIteratorType) :: iterator
35  ! -- local
36  type(KeyValueListType), pointer :: first_bucket
37 
38  iterator%buckets => buckets
39 
40  first_bucket => iterator%buckets(1)
41  allocate (iterator%current_bucket_iterator, source=first_bucket%iterator())
42 
Here is the caller graph for this function:

◆ has_next()

type(logical) function ptrhashtableiteratormodule::has_next ( class(ptrhashtableiteratortype this)
private

Definition at line 48 of file PtrHashTableIterator.f90.

49  class(PtrHashTableIteratorType) :: this
50  type(logical) :: res
51  ! -- local
52  type(KeyValueListType), pointer :: bucket
53  integer(I4B) :: bucket_index
54 
55  !
56  ! -- check if there are more values in the current bucket
57  if (this%current_bucket_iterator%has_next()) then
58  res = .true.
59  return
60  end if
61 
62  !
63  ! -- check if there is a next bucket which has values.
64  ! -- if so then there is more to iterate through.
65  do bucket_index = this%curent_bucket_index + 1, size(this%buckets)
66  bucket => this%buckets(bucket_index)
67  if (bucket%count() > 0) then
68  res = .true.
69  return
70  end if
71  end do
72 
73  res = .false.
74 

◆ next()

subroutine ptrhashtableiteratormodule::next ( class(ptrhashtableiteratortype this)
private

Definition at line 80 of file PtrHashTableIterator.f90.

81  class(PtrHashTableIteratorType) :: this
82  ! -- local
83  type(KeyValueListType), pointer :: bucket !< a bucket
84  integer(I4B) :: bucket_index
85 
86  !
87  ! -- If the current bucket doesn't have anymore values continue to the next
88  if (.not. this%current_bucket_iterator%has_next()) then
89  do bucket_index = this%curent_bucket_index + 1, size(this%buckets)
90  bucket => this%buckets(bucket_index)
91  if (bucket%count() > 0) then
92  deallocate (this%current_bucket_iterator)
93  allocate (this%current_bucket_iterator, source=bucket%iterator())
94  this%curent_bucket_index = bucket_index
95  exit
96  end if
97  end do
98  end if
99 
100  call this%current_bucket_iterator%next()
101 

◆ value()

class(*) function, pointer ptrhashtableiteratormodule::value ( class(ptrhashtableiteratortype this)
private

Definition at line 107 of file PtrHashTableIterator.f90.

108  class(PtrHashTableIteratorType) :: this
109  class(*), pointer :: res
110 
111  res => this%current_bucket_iterator%value()
112