-
Notifications
You must be signed in to change notification settings - Fork 191
WIP: Addition of a subroutine get_other_scalar in stdlib_hashmap_wrappers #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
9a9fedb
b81e34f
e29fbd7
88e6f36
350f19b
8cb2d72
d66a3c3
05f3fe1
0afe611
1743d2c
5286c72
4d74978
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#:include "common.fypp" | ||
#:set IRLC_KINDS_TYPES = INT_KINDS_TYPES + REAL_KINDS_TYPES + LOG_KINDS_TYPES + CMPLX_KINDS_TYPES | ||
!! The module STDLIB_HASHMAP_WRAPPERS provides wrappers for various | ||
!! entities used by the hash map procedures. These include wrappers for the | ||
!! `key` and `other` data, and hashing procedures to operate on entities of | ||
|
@@ -15,7 +17,12 @@ module stdlib_hashmap_wrappers | |
int16, & | ||
int32, & | ||
int64, & | ||
dp | ||
sp, & | ||
dp, & | ||
xdp, & | ||
qp, & | ||
lk, & | ||
c_bool | ||
|
||
implicit none | ||
|
||
|
@@ -31,6 +38,7 @@ module stdlib_hashmap_wrappers | |
free_key, & | ||
free_other, & | ||
get, & | ||
get_other_scalar, & | ||
hasher_fun, & | ||
operator(==), & | ||
seeded_nmhash32_hasher, & | ||
|
@@ -87,10 +95,20 @@ end function hasher_fun | |
interface get | ||
|
||
module procedure get_char_key, & | ||
get_other, & | ||
get_int8_key | ||
|
||
end interface get | ||
|
||
interface get_other_scalar | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this go together with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be done, indeed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this commit I moved it inside the |
||
|
||
module procedure get_other_scalar_char | ||
#:for k1, t1 in IRLC_KINDS_TYPES | ||
module procedure get_other_scalar_${t1[0]}$${k1}$ | ||
#:endfor | ||
|
||
end interface get_other_scalar | ||
|
||
|
||
interface operator(==) | ||
module procedure equal_keys | ||
|
@@ -260,6 +278,63 @@ subroutine get_other( other, value ) | |
|
||
end subroutine get_other | ||
|
||
subroutine get_other_scalar_char(other, value, exists) | ||
!! Version: Experimental | ||
!! | ||
!! Gets the content of the other as a scalar of a kind provided by stdlib_kinds | ||
!! ([Specifications](../page/specs/stdlib_hashmaps.html#get_other_scalar-extracts-a-scalar-value-from-a-derived-type)) | ||
class(other_type), intent(in) :: other | ||
character(len=:), allocatable, intent(out) :: value | ||
logical, intent(out), optional :: exists | ||
|
||
logical :: exists_ | ||
|
||
exists_ = .false. | ||
|
||
if (.not.allocated(other % value)) then | ||
if (present(exists)) exists = exists_ | ||
return | ||
end if | ||
|
||
select type(d => other % value) | ||
type is ( character(*) ) | ||
value = d | ||
exists_ = .true. | ||
end select | ||
|
||
if (present(exists)) exists = exists_ | ||
|
||
end subroutine | ||
|
||
#:for k1, t1 in IRLC_KINDS_TYPES | ||
subroutine get_other_scalar_${t1[0]}$${k1}$(other, value, exists) | ||
!! Version: Experimental | ||
!! | ||
!! Gets the content of the other as a scalar of a kind provided by stdlib_kinds | ||
!! ([Specifications](../page/specs/stdlib_hashmaps.html#get_other_scalar-extracts-a-scalar-value-from-a-derived-type)) | ||
class(other_type), intent(in) :: other | ||
${t1}$, intent(out) :: value | ||
logical, intent(out), optional :: exists | ||
|
||
logical :: exists_ | ||
|
||
exists_ = .false. | ||
|
||
if (.not.allocated(other % value)) then | ||
if (present(exists)) exists = exists_ | ||
return | ||
end if | ||
|
||
select type(d => other % value) | ||
type is ( ${t1}$ ) | ||
value = d | ||
exists_ = .true. | ||
end select | ||
|
||
if (present(exists)) exists = exists_ | ||
|
||
end subroutine | ||
#:endfor | ||
|
||
subroutine get_int8_key( key, value ) | ||
!! Version: Experimental | ||
|
Uh oh!
There was an error while loading. Please reload this page.