MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
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 pop (this)
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,.
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 88 of file STLVecInt.f90.

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

◆ add_array_unique()

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

Definition at line 100 of file STLVecInt.f90.

101 class(STLVecInt), intent(inout) :: this
102 integer(I4B), dimension(:), pointer :: array
103 ! local
104 integer(I4B) :: i
105
106 do i = 1, size(array)
107 if (.not. this%contains(array(i))) then
108 call this%push_back(array(i))
109 end if
110 end do
111

◆ at()

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

Definition at line 114 of file STLVecInt.f90.

115 class(STLVecInt), intent(in) :: this
116 integer(I4B), intent(in) :: idx
117 integer(I4B) :: value
118
119 value = this%values(idx)
120

◆ at_safe()

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

Definition at line 123 of file STLVecInt.f90.

124 class(STLVecInt), intent(inout) :: this
125 integer(I4B), intent(in) :: idx
126 integer(I4B) :: value
127
128 if (idx > this%size) then
129 write (*, *) 'STLVecInt exception: access out of bounds, index ', idx, &
130 ' exceeds actual size (', this%size, ')'
131 call ustop()
132 end if
133 value = this%at(idx)
134
Here is the call graph for this function:

◆ clear()

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

Definition at line 146 of file STLVecInt.f90.

147 class(STLVecInt), intent(inout) :: this
148
149 ! really, this is all there is to it...
150 this%size = 0
151

◆ contains()

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

Definition at line 210 of file STLVecInt.f90.

211 class(STLVecInt), intent(inout) :: this
212 integer(I4B) :: val
213 logical(LGP) :: res
214 ! local
215 integer(I4B) :: i
216
217 res = .false.
218 do i = 1, this%size
219 if (this%at(i) == val) then
220 res = .true.
221 return
222 end if
223 end do
224

◆ destroy()

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

Definition at line 182 of file STLVecInt.f90.

183 class(STLVecInt), intent(inout) :: this
184
185 if (allocated(this%values)) then
186 deallocate (this%values)
187 this%size = 0
188 this%capacity = 0
189 else
190 write (*, *) 'STLVecInt exception: cannot delete an unallocated array'
191 call ustop()
192 end if
193
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 198 of file STLVecInt.f90.

199 class(STLVecInt), intent(inout) :: this
200 integer(I4B) :: increment
201
202 ! expansion strategy
203 increment = this%capacity / 2 + 1
204 call expandarray(this%values, increment)
205 this%capacity = this%capacity + increment
206

◆ get_index()

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

Definition at line 229 of file STLVecInt.f90.

230 class(STLVecInt), intent(inout) :: this
231 integer(I4B) :: val
232 integer(I4B) :: idx
233 ! local
234 integer(I4B) :: i
235
236 idx = -1
237 do i = 1, this%size
238 if (this%at(i) == val) then
239 idx = i
240 return
241 end if
242 end do
243

◆ get_values()

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

Definition at line 246 of file STLVecInt.f90.

247 class(STLVecInt), intent(in) :: this
248 integer(I4B), dimension(:), allocatable :: values
249
250 values = this%values(1:this%size)
251

◆ init()

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

Definition at line 38 of file STLVecInt.f90.

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

◆ pop()

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

Definition at line 76 of file STLVecInt.f90.

77 class(STLVecInt), intent(inout) :: this
78
79 if (this%size > 0) then
80 this%size = this%size - 1
81 else
82 write (*, *) 'STLVecInt exception: cannot pop from an empty array'
83 call ustop()
84 end if
85
Here is the call graph for this function:

◆ push_back()

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

Definition at line 53 of file STLVecInt.f90.

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

◆ push_back_unique()

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

Definition at line 66 of file STLVecInt.f90.

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

◆ set()

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

Definition at line 137 of file STLVecInt.f90.

138 class(STLVecInt), intent(inout) :: this
139 integer(I4B), intent(in) :: idx
140 integer(I4B) :: value
141
142 this%values(idx) = value
143

◆ shrink_to_fit()

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

Definition at line 154 of file STLVecInt.f90.

155 class(STLVecInt), intent(inout) :: this
156 ! local
157 integer(I4B), allocatable :: tempValues(:)
158 integer(I4B) :: i, newSize
159
160 if (this%size == this%capacity) then
161 return
162 end if
163
164 ! store temp
165 newsize = this%size
166 allocate (tempvalues(newsize))
167 do i = 1, newsize
168 tempvalues(i) = this%values(i)
169 end do
170
171 ! reinit
172 call this%destroy()
173 call this%init(newsize)
174
175 ! copy back
176 do i = 1, newsize
177 call this%push_back(tempvalues(i))
178 end do
179

Variable Documentation

◆ defaultinitialcapacity

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

Definition at line 9 of file STLVecInt.f90.