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

Data Types

type  keyvaluelisttype
 A list that stores items as a key-value pair. More...
 

Functions/Subroutines

class(iteratortype) function, allocatable iterator (this)
 
subroutine add (this, key, val)
 Add a key-value pair to the list. More...
 
class(*) function, pointer get (this, key)
 Get a value using a key. More...
 
integer(i4b) function count (this)
 The nummer of items in the list. More...
 
subroutine clear (this)
 Clears the list. More...
 
recursive subroutine clear_node (node)
 Clears the node. More...
 

Function/Subroutine Documentation

◆ add()

subroutine keyvaluelistmodule::add ( class(keyvaluelisttype this,
character(len=*), intent(in)  key,
class(*), intent(in), pointer  val 
)
private

The list uses an 'append to end' approach for adding items

Definition at line 42 of file KeyValueList.f90.

43  class(KeyValueListType) :: this
44  character(len=*), intent(in) :: key
45  class(*), pointer, intent(in) :: val
46  ! -- local
47 
48  if (.not. associated(this%first)) then
49  allocate (this%first)
50  this%last => this%first
51  else
52  allocate (this%last%next)
53  this%last => this%last%next
54  end if
55 
56  allocate (this%last%key)
57  this%last%key = key
58  this%last%value => val
59  this%last%next => null()
60 
61  this%cnt = this%cnt + 1
62 

◆ clear()

subroutine keyvaluelistmodule::clear ( class(keyvaluelisttype this)
private

clears all the nodes of the list

Definition at line 103 of file KeyValueList.f90.

104  class(KeyValueListType) :: this
105 
106  if (associated(this%first)) call clear_node(this%first)
107  this%first => null()
108  this%last => null()
109  this%cnt = 0
110 
Here is the call graph for this function:

◆ clear_node()

recursive subroutine keyvaluelistmodule::clear_node ( type(keyvaluenodetype), pointer  node)
private

Recursive method that clears the next node before clearing itself

Definition at line 117 of file KeyValueList.f90.

118  type(KeyValueNodeType), pointer :: node
119 
120  if (associated(node)) then
121  call clear_node(node%next)
122 
123  deallocate (node%key)
124 
125  nullify (node%key)
126  nullify (node%value)
127  nullify (node%next)
128 
129  deallocate (node)
130  end if
131 
Here is the caller graph for this function:

◆ count()

integer(i4b) function keyvaluelistmodule::count ( class(keyvaluelisttype this)
private

Definition at line 92 of file KeyValueList.f90.

93  class(KeyValueListType) :: this
94  integer(I4B) :: val
95 
96  val = this%cnt

◆ get()

class(*) function, pointer keyvaluelistmodule::get ( class(keyvaluelisttype this,
character(len=*), intent(in)  key 
)
private

If the key can't be found the return value will be a null pointer

Definition at line 69 of file KeyValueList.f90.

70  class(KeyValueListType) :: this
71  character(len=*), intent(in) :: key
72  class(*), pointer :: val
73  ! -- local
74  type(KeyValueNodeType), pointer :: node !< current node in the list
75 
76  val => null()
77  node => this%first
78 
79  do while (associated(node))
80  if (node%key == key) then
81  val => node%value
82  exit
83  end if
84  node => node%next
85  end do
86 

◆ iterator()

class(iteratortype) function, allocatable keyvaluelistmodule::iterator ( class(keyvaluelisttype this)
private

Definition at line 31 of file KeyValueList.f90.

32  class(KeyValueListType) :: this
33  class(IteratorType), allocatable :: itr
34 
35  itr = keyvaluelistiteratortype(this%first)