-
Notifications
You must be signed in to change notification settings - Fork 194
Hashmap test update #1025
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
Open
chuckyvt
wants to merge
8
commits into
fortran-lang:master
Choose a base branch
from
chuckyvt:hashmap-test-update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hashmap test update #1025
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6c3d3df
Hashmap-test-update
chuckyvt 0b31288
Update test_maps.f90
chuckyvt b1dab28
Update test_maps.f90
chuckyvt 8303b2b
Abstract type example
chuckyvt a1111f9
Update example/hashmaps/example_hashmaps_abstract_type.f90
chuckyvt 319b1f8
Update example/hashmaps/example_hashmaps_abstract_type.f90
chuckyvt fa90e04
Update stdlib_hashmaps.md
chuckyvt e5c9065
Merge branch 'hashmap-test-update' of https://github.com/chuckyvt/std…
chuckyvt 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 hidden or 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 hidden or 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 @@ | ||
|
||
! For procedure interfaces, consider using abstract hashmap_type for interface definition. | ||
! This allows the procedure to be used for both chaining and open hashmap types. | ||
|
||
program example_abstract_type | ||
use stdlib_kinds, only: int8, int64 | ||
chuckyvt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
use stdlib_hashmaps, only: chaining_hashmap_type, open_hashmap_type, hashmap_type | ||
|
||
implicit none | ||
|
||
integer :: out_value | ||
type(chaining_hashmap_type) :: chaining_map | ||
type(open_hashmap_type) :: open_map | ||
|
||
! Chaining map call | ||
call put_int(chaining_map, '1', 1) | ||
call get_int(chaining_map, '1', out_value) | ||
print *, "Chaining out value is ", out_value | ||
|
||
! Open map call | ||
call put_int(open_map, '1', 1) | ||
call get_int(open_map, '1', out_value) | ||
print *, "Open out value is ", out_value | ||
|
||
contains | ||
|
||
subroutine put_int(map, key, value) | ||
class(hashmap_type), intent(inout) :: map | ||
character(len=*), intent(in) :: key | ||
integer, intent(in) :: value | ||
|
||
call map%map_entry(key, value) | ||
end subroutine put_int | ||
|
||
|
||
subroutine get_int(map, key, value) | ||
class(hashmap_type), intent(inout) :: map | ||
character(len=*), intent(in) :: key | ||
integer, intent(out) :: value | ||
class(*), allocatable :: data | ||
|
||
call map%get_other_data( key, data) | ||
|
||
select type (data) | ||
type is (integer) | ||
value = data | ||
class default | ||
print *, 'Invalid data type in other' | ||
end select | ||
end subroutine get_int | ||
|
||
|
||
end program example_abstract_type |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.