Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
njansson committed Jan 23, 2025
2 parents 7b29971 + 24baacc commit 6f24515
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 80 deletions.
68 changes: 34 additions & 34 deletions src/adt/htable.f90
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ end function htable_hash
! Integer based implementation
!
interface

!> Initialize an integer based hash table
module subroutine htable_i4_init(this, size, data)
class(htable_i4_t), intent(inout) :: this
Expand Down Expand Up @@ -295,7 +295,7 @@ end function htable_i4_hash
!> Remove an integer with key @a key from the hash table
module subroutine htable_i4_remove(this, key)
class(htable_i4_t), intent(inout) :: this
integer, intent(inout) :: key !< Table key
integer, intent(inout) :: key !< Table key
end subroutine htable_i4_remove

!> Initialize an integer based hash table iterator
Expand All @@ -320,21 +320,21 @@ end function htable_iter_i4_value
module function htable_iter_i4_key(this) result(key)
class(htable_iter_i4_t), target, intent(inout) :: this
integer, pointer :: key
end function htable_iter_i4_key
end function htable_iter_i4_key

end interface

!
! Integer*8 based implementation
!
interface

!> Initialize an integer*8 based hash table
!! @param size Initial size of the table
!! @param data to associate with @a key
module subroutine htable_i8_init(this, size, data)
class(htable_i8_t), intent(inout) :: this
integer, value :: size
integer, value :: size
class(*), intent(inout), optional :: data
end subroutine htable_i8_init

Expand All @@ -348,7 +348,7 @@ end subroutine htable_i8_free
!! @param data to be associated with @a key
recursive module subroutine htable_i8_set(this, key, data)
class(htable_i8_t), intent(inout) :: this
integer(kind=i8), intent(inout) :: key
integer(kind=i8), intent(inout) :: key
class(*), intent(inout) :: data
end subroutine htable_i8_set

Expand Down Expand Up @@ -393,7 +393,7 @@ module function htable_iter_i8_value(this) result(value)
class(htable_iter_i8_t), target, intent(inout) :: this
integer(kind=i8), pointer :: value
end function htable_iter_i8_value

!> Return the current key of the integer*8 based hash table iterator
module function htable_iter_i8_key(this) result(key)
class(htable_iter_i8_t), target, intent(inout) :: this
Expand All @@ -406,7 +406,7 @@ end function htable_iter_i8_key
! Double precision based implementation
!
interface

!> Initialize a double precision based hash table
!! @param size Initial size of the table
!! @param data to associate with @a key
Expand All @@ -420,13 +420,13 @@ end subroutine htable_r8_init
module subroutine htable_r8_free(this)
class(htable_r8_t), intent(inout) :: this
end subroutine htable_r8_free

!> Insert a double precision @a key (with @a data) into the hash table
!! @param key in the hash table
!! @param data to be associated with @a key
recursive module subroutine htable_r8_set(this, key, data)
class(htable_r8_t), intent(inout) :: this
real(kind=dp), intent(inout) :: key
real(kind=dp), intent(inout) :: key
class(*), intent(inout) :: data
end subroutine htable_r8_set

Expand All @@ -452,7 +452,7 @@ end function htable_r8_hash
!! @param key to be removed
module subroutine htable_r8_remove(this, key)
class(htable_r8_t), intent(inout) :: this
real(kind=dp), intent(inout) :: key
real(kind=dp), intent(inout) :: key
end subroutine htable_r8_remove

!> Initialize a double precision based hash table iterator
Expand All @@ -465,7 +465,7 @@ end subroutine htable_iter_r8_init
module subroutine htable_iter_r8_free(this)
type(htable_iter_r8_t), intent(inout) :: this
end subroutine htable_iter_r8_free

!> Return the current value of the double precision based hash table iterator
module function htable_iter_r8_value(this) result(value)
class(htable_iter_r8_t), target, intent(inout) :: this
Expand All @@ -484,13 +484,13 @@ end function htable_iter_r8_key
! Point based implementation
!
interface

!> Initialize a point based hash table
!! @param size Initial size of the table
!! @param data to associate with @a key
module subroutine htable_pt_init(this, size, data)
class(htable_pt_t), intent(inout) :: this
integer, value :: size
integer, value :: size
class(*), intent(inout), optional :: data
end subroutine htable_pt_init

Expand All @@ -505,16 +505,16 @@ end subroutine htable_pt_free
recursive module subroutine htable_pt_set(this, key, data)
class(htable_pt_t), intent(inout) :: this
type(point_t), intent(inout) :: key
class(*), intent(inout) :: data
class(*), intent(inout) :: data
end subroutine htable_pt_set

!> Retrive a point with key @a key from the hash table
!! @param key used to retrieve data
!! @param data returned entry (with @a key) from the hash table
module function htable_pt_get(this, key, data) result(rcode)
class(htable_pt_t), intent(inout) :: this
type(point_t), intent(inout) :: key
class(*), intent(inout) :: data
type(point_t), intent(inout) :: key
class(*), intent(inout) :: data
integer :: rcode
end function htable_pt_get

Expand All @@ -530,9 +530,9 @@ end function htable_pt_hash
!! @param key to be removed
module subroutine htable_pt_remove(this, key)
class(htable_pt_t), intent(inout) :: this
type(point_t), intent(inout) :: key
type(point_t), intent(inout) :: key
end subroutine htable_pt_remove

!> Initialize a point based hash table iterator
module subroutine htable_iter_pt_init(this, t)
class(htable_iter_pt_t), intent(inout) :: this
Expand All @@ -543,13 +543,13 @@ end subroutine htable_iter_pt_init
module subroutine htable_iter_pt_free(this)
type(htable_iter_pt_t), intent(inout) :: this
end subroutine htable_iter_pt_free

!> Return the current value of the point based hash table iterator
module function htable_iter_pt_value(this) result(value)
class(htable_iter_pt_t), target, intent(inout) :: this
type(point_t), pointer :: value
end function htable_iter_pt_value

!> Return the current key of the point based hash table iterator
module function htable_iter_pt_key(this) result(key)
class(htable_iter_pt_t), target, intent(inout) :: this
Expand All @@ -562,27 +562,27 @@ end function htable_iter_pt_key
! Integer 2-tuple based implementation
!
interface

!> Initialize an integer 2-tuple hash table
!! @param size Initial size of the table
!! @param data to associate with @a key
module subroutine htable_i4t2_init(this, size, data)
class(htable_i4t2_t), intent(inout) :: this
integer, value :: size
class(*), intent(inout), optional :: data
integer, value :: size
class(*), intent(inout), optional :: data
end subroutine htable_i4t2_init

!> Destroy an integer 2-tuple based hash table
module subroutine htable_i4t2_free(this)
class(htable_i4t2_t), intent(inout) :: this
end subroutine htable_i4t2_free

!> Insert an integer 2-tuple into the hash table
!! @param key in the hash table
!! @param data to be associated with @a key
recursive module subroutine htable_i4t2_set(this, key, data)
class(htable_i4t2_t), intent(inout) :: this
type(tuple_i4_t), intent(inout) :: key !< Table key
type(tuple_i4_t), intent(inout) :: key !< Table key
class(*), intent(inout) :: data !< Data associated with @a key
end subroutine htable_i4t2_set

Expand All @@ -608,7 +608,7 @@ end function htable_i4t2_hash
!! @param key to be removed
module subroutine htable_i4t2_remove(this, key)
class(htable_i4t2_t), intent(inout) :: this
type(tuple_i4_t), intent(inout) :: key !< Table key
type(tuple_i4_t), intent(inout) :: key !< Table key
end subroutine htable_i4t2_remove

!> Initialize an integer 2-tuple based hash table iterator
Expand Down Expand Up @@ -640,7 +640,7 @@ end function htable_iter_i4t2_key
! Integer 4-tuple based implementation
!
interface

!> Initialize an integer 4-tuple hash table
!! @param size Initial size of the table
!! @param data to associate with @a key
Expand Down Expand Up @@ -718,7 +718,7 @@ end function htable_iter_i4t4_key
! C pointer based implementation
!
interface

!> Initialize a C pointer based hash table
!! @param size Initial size of the table
!! @param data to associate with @a key
Expand Down Expand Up @@ -772,7 +772,7 @@ module subroutine htable_iter_cptr_init(this, t)
class(htable_iter_cptr_t), intent(inout) :: this
type(htable_cptr_t), target, intent(inout) :: t
end subroutine htable_iter_cptr_init

!> Destroy a C pointer based hash table iterator
module subroutine htable_iter_cptr_free(this)
type(htable_iter_cptr_t), intent(inout) :: this
Expand All @@ -791,7 +791,7 @@ module function htable_iter_cptr_key(this) result(key)
end function htable_iter_cptr_key

end interface

contains

!> Destroy a hash table
Expand All @@ -806,11 +806,11 @@ subroutine htable_free(this)
if (allocated(this%valid)) then
deallocate(this%valid)
end if
if (allocated(this%skip)) then

if (allocated(this%skip)) then
deallocate(this%skip)
end if

this%size = 0
this%entries = 0

Expand Down
12 changes: 6 additions & 6 deletions src/adt/htable_cptr.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
implicit none

contains

!> Initialize a C pointer based hash table
module subroutine htable_cptr_init(this, size, data)
class(htable_cptr_t), intent(inout) :: this
Expand All @@ -19,7 +19,7 @@ module subroutine htable_cptr_init(this, size, data)

allocate(this%key(0:size))
if (present(data)) then
allocate(this%data(0:size), source=data)
allocate(this%data(0:size), source=data)
else
allocate(h_cptr_t::this%data(0:size))
end if
Expand All @@ -41,7 +41,7 @@ module subroutine htable_cptr_free(this)
end if

call this%free_base()

end subroutine htable_cptr_free

!> Insert a C pointer into the hash table
Expand All @@ -53,7 +53,7 @@ recursive module subroutine htable_cptr_set(this, key, data)
integer index, i, c

c = 0
i = log(1.0/this%size)/log(0.6)
i = log(1.0/this%size)/log(0.6)
index = 0

do while (i .ge. 0)
Expand Down Expand Up @@ -81,7 +81,7 @@ recursive module subroutine htable_cptr_set(this, key, data)
call tmp%init(ishft(this%size, 1), data)

do i = 0, this%size - 1
if (this%valid(i)) then
if (this%valid(i)) then
select type (datap => this%data(i))
type is (integer)
call tmp%set(this%key(i), datap)
Expand Down Expand Up @@ -241,5 +241,5 @@ module function htable_iter_cptr_key(this) result(key)
end select

end function htable_iter_cptr_key

end submodule htable_cptr
10 changes: 5 additions & 5 deletions src/adt/htable_i4.f90
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module subroutine htable_i4_init(this, size, data)

allocate(this%key(0:size))
if (present(data)) then
allocate(this%data(0:size), source=data)
allocate(this%data(0:size), source=data)
else
allocate(integer::this%data(0:size))
end if
Expand All @@ -74,7 +74,7 @@ module subroutine htable_i4_free(this)
end if

call this%free_base()

end subroutine htable_i4_free

!> Insert an integer into the hash table
Expand All @@ -86,7 +86,7 @@ recursive module subroutine htable_i4_set(this, key, data)
integer index, i, c

c = 0
i = log(1.0/this%size)/log(0.6)
i = log(1.0/this%size)/log(0.6)
index = 0

do while (i .ge. 0)
Expand Down Expand Up @@ -114,7 +114,7 @@ recursive module subroutine htable_i4_set(this, key, data)
call tmp%init(ishft(this%size, 1), data)

do i = 0, this%size - 1
if (this%valid(i)) then
if (this%valid(i)) then
select type (datap => this%data(i))
type is (integer)
call tmp%set(this%key(i), datap)
Expand Down Expand Up @@ -182,7 +182,7 @@ module function htable_i4_get(this, key, data) result(rcode)
c = c + 1
end do
rcode = 1

end function htable_i4_get

!> Hash function for an integer based hash table
Expand Down
Loading

0 comments on commit 6f24515

Please sign in to comment.