13 integer(I4B),
private,
allocatable :: values(:)
15 integer(I4B) :: capacity
17 procedure, pass(this) ::
init
22 procedure, pass(this) ::
at
24 procedure, pass(this) ::
set
32 procedure,
private, pass(this) ::
expand
37 subroutine init(this, capacity)
39 integer(I4B),
intent(in),
optional :: capacity
41 if (
present(capacity))
then
42 this%capacity = capacity
47 allocate (this%values(this%capacity))
54 integer(I4B) :: newValue
56 if (this%size + 1 > this%capacity)
then
60 this%size = this%size + 1
61 this%values(this%size) = newvalue
67 integer(I4B) :: newValue
69 if (.not. this%contains(newvalue))
then
70 call this%push_back(newvalue)
77 integer(I4B),
dimension(:),
pointer :: array
82 call this%push_back(array(i))
89 integer(I4B),
dimension(:),
pointer :: array
94 if (.not. this%contains(array(i)))
then
95 call this%push_back(array(i))
101 function at(this, idx)
result(value)
103 integer(I4B),
intent(in) :: idx
104 integer(I4B) :: value
106 value = this%values(idx)
112 integer(I4B),
intent(in) :: idx
113 integer(I4B) :: value
115 if (idx > this%size)
then
116 write (*, *)
'STLVecInt exception: access out of bounds, index ', idx, &
117 ' exceeds actual size (', this%size,
')'
124 subroutine set(this, idx, value)
126 integer(I4B),
intent(in) :: idx
127 integer(I4B) :: value
129 this%values(idx) =
value
144 integer(I4B),
allocatable :: tempValues(:)
145 integer(I4B) :: i, newSize
147 if (this%size == this%capacity)
then
153 allocate (tempvalues(newsize))
155 tempvalues(i) = this%values(i)
160 call this%init(newsize)
164 call this%push_back(tempvalues(i))
172 if (
allocated(this%values))
then
173 deallocate (this%values)
177 write (*, *)
'STLVecInt exception: cannot delete an unallocated array'
187 integer(I4B) :: increment
190 increment = this%capacity / 2 + 1
192 this%capacity = this%capacity + increment
206 if (this%at(i) == val)
then
225 if (this%at(i) == val)
then
235 integer(I4B),
dimension(:),
allocatable :: values
237 values = this%values(1:this%size)
This module defines variable data types.
This module contains simulation methods.
subroutine, public ustop(stopmess, ioutlocal)
Stop the simulation.
subroutine push_back_unique(this, newValue)
subroutine set(this, idx, value)
subroutine push_back(this, newValue)
subroutine shrink_to_fit(this)
integer(i4b) function at_safe(this, idx)
integer(i4b) function, dimension(:), allocatable get_values(this)
logical(lgp) function contains(this, val)
integer(i4b) function at(this, idx)
subroutine add_array(this, array)
subroutine add_array_unique(this, array)
integer(i4b) function get_index(this, val)
Return index of first occurrence,.
integer(i4b), parameter defaultinitialcapacity