subroutine set_amap_t(this,kv,vv)
class(amap_t), intent(inout) :: this
character(len=*), intent(in) :: kv
real(8), intent(in) :: vv
type(pair_t), allocatable :: tmp_pairs(:)
type(key_t) :: k
type(value_t) :: v
integer :: idx
k = kv
v = vv
if (.not. allocated(this%pairs)) then
allocate(this%pairs(this%extent))
end if
idx = this%find(k)
if (idx > 0) then
this%pairs(idx) = pair_t(k,v)
return
end if
if (this%high_water == size(this%pairs)) then
allocate(tmp_pairs(size(this%pairs)+this%extent))
tmp_pairs(1:this%high_water) = this%pairs
call move_alloc(tmp_pairs, this%pairs)
end if
this%high_water = this%high_water + 1
this%pairs(this%high_water) = pair_t(k,v)
end subroutine set_amap_t