-
Notifications
You must be signed in to change notification settings - Fork 197
Support sorting arrays of bitsets #723
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 18 commits
07c0e10
04104b1
b482534
799ce0d
bd92e37
4d3057a
a99f19d
6154e2b
423a8b4
0ee5fb1
a9254e1
e1b520c
185c695
1b0d50a
47e9c19
e27e9af
e7e6e41
5f1195f
4100e61
bdd6dcc
61029ee
7d6d979
de2dbbb
96763e1
1905c80
efbc0cc
916d83d
e661cd2
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,4 @@ | ||
| ADD_EXAMPLE(ord_sort) | ||
| ADD_EXAMPLE(sort) | ||
| ADD_EXAMPLE(radix_sort) | ||
| ADD_EXAMPLE(radix_sort) | ||
| ADD_EXAMPLE(sort_bitsetl) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| program example_sort_bitsetl | ||
| use stdlib_kinds | ||
degawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| use stdlib_sorting, only: sort | ||
| use stdlib_bitsets | ||
degawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| implicit none | ||
| type(bitset_large), allocatable :: array(:) | ||
|
|
||
| array = [bitset_l("0101"), & ! 5 | ||
| bitset_l("0100"), & ! 4 | ||
| bitset_l("0011"), & ! 3 | ||
| bitset_l("0001"), & ! 1 | ||
| bitset_l("1010"), & ! 10 | ||
| bitset_l("0100"), & ! 4 | ||
| bitset_l("1001")] ! 9 | ||
|
|
||
| call sort(array) | ||
|
|
||
| block | ||
jvdp1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| integer(int32) :: i | ||
| do i = 1, size(array) | ||
| print *, to_string(array(i)) | ||
| ! 0001 | ||
| ! 0011 | ||
| ! 0100 | ||
| ! 0100 | ||
| ! 0101 | ||
| ! 1001 | ||
| ! 1010 | ||
| end do | ||
| end block | ||
|
|
||
| deallocate(array) | ||
| contains | ||
| function bitset_l(str) result(new_bitsetl) | ||
| character(*), intent(in) :: str | ||
| type(bitset_large) :: new_bitsetl | ||
|
|
||
| call new_bitsetl%from_string(str) | ||
| end function bitset_l | ||
|
|
||
| function to_string(bitset) result(str) | ||
| type(bitset_large), intent(in) :: bitset | ||
| character(:), allocatable :: str | ||
|
|
||
| call bitset%to_string(str) | ||
| end function to_string | ||
| end program example_sort_bitsetl | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1170,8 +1170,8 @@ module stdlib_bitsets | |
| !! Version: experimental | ||
| !! | ||
| !! Used to define assignment for `bitset_large`. | ||
| type(bitset_large), intent(out) :: set1 | ||
| type(bitset_large), intent(in) :: set2 | ||
| type(bitset_large), intent(inout) :: set1 | ||
|
||
| type(bitset_large), intent(in) :: set2 | ||
| end subroutine assign_large | ||
|
|
||
jvdp1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #:for k1 in INT_KINDS | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.