-
Notifications
You must be signed in to change notification settings - Fork 182
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
Added a procedure for getting all the keys in a hashmap #741
Merged
+286
−1
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5871049
added deferred procedure & abstract interface
degawa 7396f0f
added interface of `get_all_chaining_keys`
degawa e911a70
added implementaion of `get_all_chaining_keys`
degawa 4ce674e
added interface of `get_all_open_keys`
degawa 6937b24
added implementation of `get_all_open_keys`
degawa a637f50
updated specification of stdlib_hashmaps
degawa ae2aba6
added tests for `get_all_chaining_keys`
degawa f7fa292
added tests for `get_all_open_keys`
degawa 7cde920
added an example for `get_all_keys`
degawa ff4bbd4
Update example/hashmaps/example_hashmaps_get_all_keys.f90
degawa 95a9412
fixed program name
degawa 92ff31f
added pure attribute
degawa b083fc7
replaced "presented" with "contained"
degawa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
program example_set_other_data | ||
jvdp1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use stdlib_kinds, only: int32 | ||
use stdlib_hashmaps, only: chaining_hashmap_type | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher, & | ||
key_type, other_type, set | ||
implicit none | ||
type(chaining_hashmap_type) :: map | ||
type(key_type) :: key | ||
type(other_type) :: other | ||
|
||
type(key_type), allocatable :: keys(:) | ||
integer(int32) :: i | ||
|
||
call map%init(fnv_1_hasher) | ||
|
||
! adding key-value pairs to the map | ||
call set(key, "initial key") | ||
call set(other, "value 1") | ||
call map%map_entry(key, other) | ||
|
||
call set(key, "second key") | ||
call set(other, "value 2") | ||
call map%map_entry(key, other) | ||
|
||
call set(key, "last key") | ||
call set(other, "value 3") | ||
call map%map_entry(key, other) | ||
|
||
! getting all the keys in the map | ||
call map%get_all_keys(keys) | ||
|
||
print '("Number of keys in the hashmap = ", I0)', size(keys) | ||
!Number of keys in the hashmap = 3 | ||
|
||
do i = 1, size(keys) | ||
print '("Value of key ", I0, " = ", A)', i, key_to_char(keys(i)) | ||
end do | ||
!Value of key 1 = initial key | ||
!Value of key 2 = second key | ||
!Value of key 3 = last key | ||
|
||
contains | ||
!Converts key type to character type | ||
function key_to_char(key) result(str) | ||
jvdp1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
implicit none | ||
degawa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type(key_type), intent(in) :: key | ||
character(:), allocatable :: str | ||
character(:), allocatable :: str_mold | ||
|
||
allocate( character(len=size(key%value)) :: str_mold ) | ||
str = transfer(key%value, str_mold) | ||
end function key_to_char | ||
end program example_set_other_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be "present" or "presented"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use "presented in" to mean "located in," "existing in," or "contained in" here.
I cannot answer whether "present" or "presented" is correct due to my poor English skills, so I need help to create a natural expression, especially a phrase referring to "keys in a hash map."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@milancurcic Any idea how it should be written?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jvdp1
The following expression is used in the documentation of Map in Java:
So, I would like to change "presented" to "contained" to follow this expression. I would appreciate your comments.
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@degawa "contained" sounds good to me. Please, go ahead!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @jvdp1, for giving me a supportive push forward.
I fixed the documentation for the
get_all_keys
and pushed it.I would appreciate a review.