MODFLOW 6  version 6.7.0.dev1
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...
 
subroutine clear_nodes (node)
 Clears the node and all subsequent nodes. More...
 
subroutine clear_node (node)
 Clears a single 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  call clear_nodes(this%first)
107 
108  this%first => null()
109  this%last => null()
110  this%cnt = 0
111 
Here is the call graph for this function:

◆ clear_node()

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

Definition at line 135 of file KeyValueList.f90.

136  type(KeyValueNodeType), pointer :: node
137 
138  deallocate (node%key)
139 
140  nullify (node%key)
141  nullify (node%value)
142  nullify (node%next)
143 
Here is the caller graph for this function:

◆ clear_nodes()

subroutine keyvaluelistmodule::clear_nodes ( type(keyvaluenodetype), pointer  node)
private

Definition at line 117 of file KeyValueList.f90.

118  type(KeyValueNodeType), pointer :: node
119  type(KeyValueNodeType), pointer :: next
120 
121  do while (associated(node))
122  next => node%next
123 
124  call clear_node(node)
125  deallocate (node)
126 
127  node => next
128  end do
129 
Here is the call graph for this function:
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)