File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 1
1
ADD_EXAMPLE (ord_sort )
2
2
ADD_EXAMPLE (sort )
3
- ADD_EXAMPLE (radix_sort )
3
+ ADD_EXAMPLE (radix_sort )
4
+ ADD_EXAMPLE (sort_bitsetl )
Original file line number Diff line number Diff line change
1
+ program example_sort_bitsetl
2
+ use stdlib_sorting, only: sort
3
+ use stdlib_bitsets
4
+ implicit none
5
+ type (bitset_large), allocatable :: array(:)
6
+
7
+ array = [bitset_l(" 0101" ), & ! 5
8
+ bitset_l(" 0100" ), & ! 4
9
+ bitset_l(" 0011" ), & ! 3
10
+ bitset_l(" 0001" ), & ! 1
11
+ bitset_l(" 1010" ), & ! 10
12
+ bitset_l(" 0100" ), & ! 4
13
+ bitset_l(" 1001" )] ! 9
14
+
15
+ call sort(array)
16
+
17
+ block
18
+ integer (int32) :: i
19
+ do i = 1 , size (array)
20
+ print * , to_string(array(i))
21
+ ! 0001
22
+ ! 0011
23
+ ! 0100
24
+ ! 0100
25
+ ! 0101
26
+ ! 1001
27
+ ! 1010
28
+ end do
29
+ end block
30
+
31
+ deallocate (array)
32
+ contains
33
+ function bitset_l (str ) result(new_bitsetl)
34
+ character (* ), intent (in ) :: str
35
+ type (bitset_large) :: new_bitsetl
36
+
37
+ call new_bitsetl% from_string(str)
38
+ end function bitset_l
39
+
40
+ function to_string (bitset ) result(str)
41
+ type (bitset_large), intent (in ) :: bitset
42
+ character (:), allocatable :: str
43
+
44
+ call bitset% to_string(str)
45
+ end function to_string
46
+ end program example_sort_bitsetl
You can’t perform that action at this time.
0 commit comments