MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
stlvecintmodule Module Reference

Data Types

type  stlvecint
 

Functions/Subroutines

subroutine init (this, capacity)
 
subroutine push_back (this, newValue)
 
subroutine push_back_unique (this, newValue)
 
subroutine add_array (this, array)
 
subroutine add_array_unique (this, array)
 
integer(i4b) function at (this, idx)
 
integer(i4b) function at_safe (this, idx)
 
subroutine set (this, idx, value)
 
subroutine clear (this)
 
subroutine shrink_to_fit (this)
 
subroutine destroy (this)
 
subroutine expand (this)
 
logical(lgp) function contains (this, val)
 
integer(i4b) function get_index (this, val)
 Return index of first occurrence,. More...
 
integer(i4b) function, dimension(:), allocatable get_values (this)
 

Variables

integer(i4b), parameter defaultinitialcapacity = 4
 

Function/Subroutine Documentation

◆ add_array()

subroutine stlvecintmodule::add_array ( class(stlvecint), intent(inout)  this,
integer(i4b), dimension(:), pointer  array 
)
private

Definition at line 75 of file STLVecInt.f90.

76  class(STLVecInt), intent(inout) :: this
77  integer(I4B), dimension(:), pointer :: array
78  ! local
79  integer(I4B) :: i
80 
81  do i = 1, size(array)
82  call this%push_back(array(i))
83  end do
84 

◆ add_array_unique()

subroutine stlvecintmodule::add_array_unique ( class(stlvecint), intent(inout)  this,
integer(i4b), dimension(:), pointer  array 
)
private

Definition at line 87 of file STLVecInt.f90.

88  class(STLVecInt), intent(inout) :: this
89  integer(I4B), dimension(:), pointer :: array
90  ! local
91  integer(I4B) :: i
92 
93  do i = 1, size(array)
94  if (.not. this%contains(array(i))) then
95  call this%push_back(array(i))
96  end if
97  end do
98 

◆ at()

integer(i4b) function stlvecintmodule::at ( class(stlvecint), intent(in)  this,
integer(i4b), intent(in)  idx 
)
private

Definition at line 101 of file STLVecInt.f90.

102  class(STLVecInt), intent(in) :: this
103  integer(I4B), intent(in) :: idx
104  integer(I4B) :: value
105 
106  value = this%values(idx)
107 

◆ at_safe()

integer(i4b) function stlvecintmodule::at_safe ( class(stlvecint), intent(inout)  this,
integer(i4b), intent(in)  idx 
)
private

Definition at line 110 of file STLVecInt.f90.

111  class(STLVecInt), intent(inout) :: this
112  integer(I4B), intent(in) :: idx
113  integer(I4B) :: value
114 
115  if (idx > this%size) then
116  write (*, *) 'STLVecInt exception: access out of bounds, index ', idx, &
117  ' exceeds actual size (', this%size, ')'
118  call ustop()
119  end if
120  value = this%at(idx)
121 
Here is the call graph for this function:

◆ clear()

subroutine stlvecintmodule::clear ( class(stlvecint), intent(inout)  this)
private

Definition at line 133 of file STLVecInt.f90.

134  class(STLVecInt), intent(inout) :: this
135 
136  ! really, this is all there is to it...
137  this%size = 0
138 

◆ contains()

logical(lgp) function stlvecintmodule::contains ( class(stlvecint), intent(inout)  this,
integer(i4b)  val 
)
private

Definition at line 197 of file STLVecInt.f90.

198  class(STLVecInt), intent(inout) :: this
199  integer(I4B) :: val
200  logical(LGP) :: res
201  ! local
202  integer(I4B) :: i
203 
204  res = .false.
205  do i = 1, this%size
206  if (this%at(i) == val) then
207  res = .true.
208  return
209  end if
210  end do
211 

◆ destroy()

subroutine stlvecintmodule::destroy ( class(stlvecint), intent(inout)  this)
private

Definition at line 169 of file STLVecInt.f90.

170  class(STLVecInt), intent(inout) :: this
171 
172  if (allocated(this%values)) then
173  deallocate (this%values)
174  this%size = 0
175  this%capacity = 0
176  else
177  write (*, *) 'STLVecInt exception: cannot delete an unallocated array'
178  call ustop()
179  end if
180 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand()

subroutine stlvecintmodule::expand ( class(stlvecint), intent(inout)  this)
private

Definition at line 185 of file STLVecInt.f90.

186  class(STLVecInt), intent(inout) :: this
187  integer(I4B) :: increment
188 
189  ! expansion strategy
190  increment = this%capacity / 2 + 1
191  call expandarray(this%values, increment)
192  this%capacity = this%capacity + increment
193 

◆ get_index()

integer(i4b) function stlvecintmodule::get_index ( class(stlvecint), intent(inout)  this,
integer(i4b)  val 
)
private

Definition at line 216 of file STLVecInt.f90.

217  class(STLVecInt), intent(inout) :: this
218  integer(I4B) :: val
219  integer(I4B) :: idx
220  ! local
221  integer(I4B) :: i
222 
223  idx = -1
224  do i = 1, this%size
225  if (this%at(i) == val) then
226  idx = i
227  return
228  end if
229  end do
230 

◆ get_values()

integer(i4b) function, dimension(:), allocatable stlvecintmodule::get_values ( class(stlvecint), intent(in)  this)
private

Definition at line 233 of file STLVecInt.f90.

234  class(STLVecInt), intent(in) :: this
235  integer(I4B), dimension(:), allocatable :: values
236 
237  values = this%values(1:this%size)
238 

◆ init()

subroutine stlvecintmodule::init ( class(stlvecint), intent(inout)  this,
integer(i4b), intent(in), optional  capacity 
)
private

Definition at line 37 of file STLVecInt.f90.

38  class(STLVecInt), intent(inout) :: this
39  integer(I4B), intent(in), optional :: capacity ! the initial capacity, when given
40 
41  if (present(capacity)) then
42  this%capacity = capacity
43  else
44  this%capacity = defaultinitialcapacity
45  end if
46 
47  allocate (this%values(this%capacity))
48  this%size = 0
49 

◆ push_back()

subroutine stlvecintmodule::push_back ( class(stlvecint), intent(inout)  this,
integer(i4b)  newValue 
)
private

Definition at line 52 of file STLVecInt.f90.

53  class(STLVecInt), intent(inout) :: this
54  integer(I4B) :: newValue
55  ! check capacity
56  if (this%size + 1 > this%capacity) then
57  call this%expand()
58  end if
59 
60  this%size = this%size + 1
61  this%values(this%size) = newvalue
62 

◆ push_back_unique()

subroutine stlvecintmodule::push_back_unique ( class(stlvecint), intent(inout)  this,
integer(i4b)  newValue 
)
private

Definition at line 65 of file STLVecInt.f90.

66  class(STLVecInt), intent(inout) :: this
67  integer(I4B) :: newValue
68 
69  if (.not. this%contains(newvalue)) then
70  call this%push_back(newvalue)
71  end if
72 

◆ set()

subroutine stlvecintmodule::set ( class(stlvecint), intent(inout)  this,
integer(i4b), intent(in)  idx,
integer(i4b)  value 
)
private

Definition at line 124 of file STLVecInt.f90.

125  class(STLVecInt), intent(inout) :: this
126  integer(I4B), intent(in) :: idx
127  integer(I4B) :: value
128 
129  this%values(idx) = value
130 

◆ shrink_to_fit()

subroutine stlvecintmodule::shrink_to_fit ( class(stlvecint), intent(inout)  this)
private

Definition at line 141 of file STLVecInt.f90.

142  class(STLVecInt), intent(inout) :: this
143  ! local
144  integer(I4B), allocatable :: tempValues(:)
145  integer(I4B) :: i, newSize
146 
147  if (this%size == this%capacity) then
148  return
149  end if
150 
151  ! store temp
152  newsize = this%size
153  allocate (tempvalues(newsize))
154  do i = 1, newsize
155  tempvalues(i) = this%values(i)
156  end do
157 
158  ! reinit
159  call this%destroy()
160  call this%init(newsize)
161 
162  ! copy back
163  do i = 1, newsize
164  call this%push_back(tempvalues(i))
165  end do
166 

Variable Documentation

◆ defaultinitialcapacity

integer(i4b), parameter stlvecintmodule::defaultinitialcapacity = 4
private

Definition at line 9 of file STLVecInt.f90.

9  integer(I4B), parameter :: defaultInitialCapacity = 4