-
Notifications
You must be signed in to change notification settings - Fork 191
hashmap-init-update #974
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
Merged
Merged
hashmap-init-update #974
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b2e08d5
hashmap-init-update
chuckyvt 91f42cf
Update example/hashmaps/example_hashmaps_get_all_keys.f90
chuckyvt f49759e
Update test/hashmaps/test_chaining_maps.f90
chuckyvt f54132a
Update test/hashmaps/test_open_maps.f90
chuckyvt 43779e2
Initialization flag add
chuckyvt 5cc1c9f
Update example/hashmaps/example_hashmaps_init.f90
chuckyvt 2e8e686
Merge branch 'hashmap-init-update' of https://github.com/chuckyvt/std…
chuckyvt ce8703e
Removed redundant initialization update
chuckyvt 9496beb
Update stdlib_hashmap_chaining.f90
chuckyvt 2aae214
Minor formatting change
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
program example_calls | ||
use stdlib_hashmaps, only: chaining_hashmap_type, int_calls | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher | ||
implicit none | ||
type(chaining_hashmap_type) :: map | ||
integer(int_calls) :: initial_calls | ||
call map%init(fnv_1_hasher) | ||
call map%init() | ||
initial_calls = map%calls() | ||
print *, "INITIAL_CALLS = ", initial_calls | ||
end program example_calls |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
program example_entries | ||
use stdlib_hashmaps, only: open_hashmap_type, int_index | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher | ||
implicit none | ||
type(open_hashmap_type) :: map | ||
integer(int_index) :: initial_entries | ||
call map%init(fnv_1_hasher) | ||
call map%init() | ||
initial_entries = map%entries() | ||
print *, "INITIAL_ENTRIES = ", initial_entries | ||
end program example_entries |
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
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 |
---|---|---|
@@ -1,7 +1,26 @@ | ||
program example_init | ||
use stdlib_hashmaps, only: chaining_hashmap_type | ||
use stdlib_hashmaps, only: chaining_hashmap_type, open_hashmap_type | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher | ||
implicit none | ||
type(chaining_hashmap_type) :: map | ||
call map%init(fnv_1_hasher, slots_bits=10) | ||
logical :: present | ||
|
||
|
||
!If default values are used, then init can be typically be skipped as the first map_entry call will initialize the map using default values. | ||
call map%map_entry('key', 'value') | ||
call map%key_test('key', present) | ||
print *, "Key exists without explicit init call = ", present | ||
|
||
! Init can be called to clear all items in a map. | ||
call map%init() | ||
call map%key_test('key', present) | ||
print *, "Key exists after re-initalization = ", present | ||
|
||
! User can optional specify hasher type and slots_bits instead of using default values. | ||
! Number of slots in the hashmap will initially equal 2**slots_bits. | ||
! The hashmap will autmoatically re-size as needed, however for better performance, a rule of thumb is to size so that number of slots is ~2X expected number of entries. | ||
chuckyvt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
! In this example with slots_bits=10, there will initially be 1024 slots in the map. | ||
call map%init(hasher=fnv_1_hasher, slots_bits=10) | ||
call map%map_entry('key', 'value') | ||
|
||
end program example_init |
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
program example_key_test | ||
use stdlib_kinds, only: int8 | ||
use stdlib_hashmaps, only: chaining_hashmap_type | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher, key_type, set | ||
use stdlib_hashmap_wrappers, only: key_type, set | ||
implicit none | ||
type(chaining_hashmap_type) :: map | ||
type(key_type) :: key | ||
logical :: present | ||
call map%init(fnv_1_hasher) | ||
|
||
call map%init() | ||
call set(key, [0_int8, 1_int8]) | ||
call map%key_test(key, present) | ||
print *, "Initial key of 10 present for empty map = ", present | ||
|
||
end program example_key_test |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
program example_loading | ||
use stdlib_hashmaps, only: open_hashmap_type | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher | ||
implicit none | ||
type(open_hashmap_type) :: map | ||
real :: ratio | ||
call map%init(fnv_1_hasher) | ||
call map%init() | ||
ratio = map%loading() | ||
print *, "Initial loading = ", ratio | ||
end program example_loading |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
program example_num_slots | ||
use stdlib_hashmaps, only: chaining_hashmap_type, int_index | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher | ||
implicit none | ||
type(chaining_hashmap_type) :: map | ||
integer(int_index) :: initial_slots | ||
call map%init(fnv_1_hasher) | ||
call map%init() | ||
initial_slots = map%num_slots() | ||
print *, "Initial slots = ", initial_slots | ||
end program example_num_slots |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
program example_probes | ||
use stdlib_hashmaps, only: chaining_hashmap_type | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher | ||
implicit none | ||
type(chaining_hashmap_type) :: map | ||
integer :: nprobes | ||
call map%init(fnv_1_hasher) | ||
call map%init() | ||
nprobes = map%map_probes() | ||
print *, "Initial probes = ", nprobes | ||
end program example_probes |
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
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
program example_slots_bits | ||
use stdlib_hashmaps, only: chaining_hashmap_type | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher | ||
implicit none | ||
type(chaining_hashmap_type) :: map | ||
integer :: bits | ||
call map%init(fnv_1_hasher) | ||
call map%init() | ||
bits = map%slots_bits() | ||
print *, "Initial slot bits = ", bits | ||
end program example_slots_bits |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
program example_total_depth | ||
use stdlib_hashmaps, only: chaining_hashmap_type, int_depth | ||
use stdlib_hashmap_wrappers, only: fnv_1_hasher | ||
implicit none | ||
type(chaining_hashmap_type) :: map | ||
integer(int_depth) :: initial_depth | ||
call map%init(fnv_1_hasher) | ||
call map%init() | ||
initial_depth = map%total_depth() | ||
print *, "Initial total depth = ", initial_depth | ||
end program example_total_depth |
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.