Skip to content
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

String list new #680

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
263a652
Add module for list of strings
arjenmarkus Feb 3, 2021
90b06ff
Correct typo
arjenmarkus Feb 4, 2021
4157ed1
Merge remote-tracking branch 'upstream/master' into string-list-new
arjenmarkus Jun 3, 2021
e36f997
Merge branch 'master' into string-list-new
arjenmarkus Sep 18, 2022
024b078
Documentation and corrected source code for linked lists
arjenmarkus Sep 18, 2022
4379fb4
Correct subdirectory for examples
arjenmarkus Sep 18, 2022
3067b9a
Move the implementations of the linked_list modules to src
arjenmarkus Sep 18, 2022
3cf3d85
Use an include statement to get the auxiliary subroutine in
arjenmarkus Sep 18, 2022
edd20fd
Use an internal routine instead for print_list
arjenmarkus Sep 18, 2022
86d2fe4
Add a CMakeLists.txt for building the examples
arjenmarkus Sep 20, 2022
327c8c1
Rename the examples to avoid conflicts
arjenmarkus Sep 20, 2022
8f2f1fa
Define a new macro to take care of the include directory
arjenmarkus Sep 20, 2022
09b7266
Adjust the CMake and CI build set-ups
arjenmarkus Sep 25, 2022
af8dd68
Rename the include file
arjenmarkus Sep 25, 2022
fae33a4
Correct the test program
arjenmarkus Sep 25, 2022
41417f4
Update test_performance.f90
arjenmarkus Sep 25, 2022
b8c18ea
Create CMakeLists.txt file for performance test program
arjenmarkus Sep 25, 2022
ca684ae
Merge branch 'master' into string-list-new
jvdp1 Dec 25, 2023
5644454
Updated documentation and source code
arjenmarkus Dec 28, 2023
e23b1ea
Adjusting the examples and fixing an INTENT() error
arjenmarkus Dec 28, 2023
b5e41c1
Merge branch 'string-list-new' of https://github.com/arjenmarkus/stdl…
arjenmarkus Dec 28, 2023
ebb84b8
Add explicit include directory
arjenmarkus Dec 28, 2023
b310239
Incorporate the auxiliary routine directly
arjenmarkus Dec 28, 2023
220791a
Correct the name of the test programs
arjenmarkus Dec 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
497 changes: 497 additions & 0 deletions doc/specs/stdlib_linked_list.md

Large diffs are not rendered by default.

487 changes: 487 additions & 0 deletions doc/specs/stdlib_stringlist.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ add_subdirectory(hashmaps)
add_subdirectory(hash_procedures)
add_subdirectory(io)
add_subdirectory(linalg)
add_subdirectory(linked_list)
add_subdirectory(logger)
add_subdirectory(math)
add_subdirectory(optval)
Expand Down
15 changes: 15 additions & 0 deletions example/linked_list/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include_directories(${CMAKE_CURRENT_LIST_DIR})

ADD_EXAMPLE(linked_absorb)
ADD_EXAMPLE(linked_clear)
ADD_EXAMPLE(linked_concat)
ADD_EXAMPLE(linked_get)
ADD_EXAMPLE(linked_insert)
ADD_EXAMPLE(linked_pop)
ADD_EXAMPLE(linked_push)
ADD_EXAMPLE(linked_remove)
ADD_EXAMPLE(linked_replace)
ADD_EXAMPLE(linked_reverse)
ADD_EXAMPLE(linked_size)
ADD_EXAMPLE(linked_slice)
ADD_EXAMPLE(linked_splice)
70 changes: 70 additions & 0 deletions example/linked_list/example_linked_absorb.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
! example_absorb.f90 --
! Demonstrate the absorb method
!
program example_absorb
use stdlib_linked_list

implicit none

type(linked_list_type) :: list, list_to_absorb

!
! Add a few elements to the two lists
!
call list%insert( "String element", 1 )
call list%insert( 2, 2 )
call list%insert( 3.3, 3 )

call list_to_absorb%insert( 5, 1 )
call list_to_absorb%insert( 6, 2 )

write(*,*) 'List 1:'
call print_list( list )
write(*,*) 'List 2:'
call print_list( list_to_absorb )

!
! Now absorb the second list to the first one
!

call list%absorb( list_to_absorb )

!
! Print the resulting list
!
write(*,*) 'New list:'
call print_list( list )

!
! Print the second list (it is untouched)
write(*,*) 'List that was absorbed (should be empty):'
call print_list( list_to_absorb )

contains
!include 'linked_list_aux.inc'
subroutine print_list( list )
type(linked_list_type), intent(in) :: list

integer :: i
class(*), pointer :: list_item

do i = 1,list%size()
list_item => list%get(i)

select type( item => list_item )
type is (integer)
write(*,*) i, item, ' (integer)'

type is (real)
write(*,*) i, item, ' (real)'

type is (character(*))
write(*,*) i, ' >', item, '< (string)'

class default
write(*,*) i, ' (type unknown)'
end select
enddo
end subroutine print_list

end program example_absorb
28 changes: 28 additions & 0 deletions example/linked_list/example_linked_clear.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
! example_clear.f90 --
! Demonstrate the clear method
!
program example_clear
use stdlib_linked_list

implicit none

type(linked_list_type) :: list

!
! Add a few elements
!
call list%insert( "String element", 1 )
call list%insert( 2, 2 )
call list%insert( 3.3, 3 )

!
! Clean up the list
!
call list%clear()

!
! The program should print 0
!
write(*,*) 'Size of the list: ', list%size()

end program example_clear
70 changes: 70 additions & 0 deletions example/linked_list/example_linked_concat.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
! example_concat.f90 --
! Demonstrate the concat method
!
program example_concat
use stdlib_linked_list

implicit none

type(linked_list_type) :: list, list_to_concat

!
! Add a few elements to the two lists
!
call list%insert( "String element", 1 )
call list%insert( 2, 2 )
call list%insert( 3.3, 3 )

call list_to_concat%insert( 5, 1 )
call list_to_concat%insert( 6, 2 )

write(*,*) 'List 1:'
call print_list( list )
write(*,*) 'List 2:'
call print_list( list_to_concat )

!
! Now concat the second list to the first one
!

call list%concat( list_to_concat )

!
! Print the resulting list
!
write(*,*) 'New list:'
call print_list( list )

!
! Print the second list (it is untouched)
write(*,*) 'List that was concatenated (remains intact):'
call print_list( list_to_concat )

contains
!include 'linked_list_aux.inc'
subroutine print_list( list )
type(linked_list_type), intent(in) :: list

integer :: i
class(*), pointer :: list_item

do i = 1,list%size()
list_item => list%get(i)

select type( item => list_item )
type is (integer)
write(*,*) i, item, ' (integer)'

type is (real)
write(*,*) i, item, ' (real)'

type is (character(*))
write(*,*) i, ' >', item, '< (string)'

class default
write(*,*) i, ' (type unknown)'
end select
enddo
end subroutine print_list

end program example_concat
41 changes: 41 additions & 0 deletions example/linked_list/example_linked_get.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
! example_get.f90 --
! Demonstrate the get method
!
program example_get
use stdlib_linked_list

implicit none

type(linked_list_type) :: list
class(*), pointer :: list_item
integer :: i

!
! Add a few elements
!
call list%insert( "String element ", 1 ) ! Note the trailing blanks
call list%insert( 2, 2 )
call list%insert( 3.3, 3 )

!
! Print the contents of the list
!
do i = 1,list%size()
list_item => list%get(i)

select type( item => list_item )
type is (integer)
write(*,*) i, item, ' (integer)'

type is (real)
write(*,*) i, item, ' (real)'

type is (character(*))
write(*,*) i, ' >', item, '< (string)'

class default
write(*,*) i, ' (type unknown)'
end select
enddo

end program example_get
59 changes: 59 additions & 0 deletions example/linked_list/example_linked_insert.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
! example_insert.f90 --
! Demonstrate the insert method
!

program example_insert
use stdlib_linked_list

implicit none

type(linked_list_type) :: list

!
! Add a few elements
!
call list%insert( "String element", 1 )
call list%insert( 2, 2 )
call list%insert( 3.3, 3 )

call print_list( list )
!
! Now insert an element in the middle
!

call list%insert( "Another string", 2 )

!
! Print the list
!
write(*,*) 'New list:'
call print_list( list )

contains
!include 'linked_list_aux.inc'
subroutine print_list( list )
type(linked_list_type), intent(in) :: list

integer :: i
class(*), pointer :: list_item

do i = 1,list%size()
list_item => list%get(i)

select type( item => list_item )
type is (integer)
write(*,*) i, item, ' (integer)'

type is (real)
write(*,*) i, item, ' (real)'

type is (character(*))
write(*,*) i, ' >', item, '< (string)'

class default
write(*,*) i, ' (type unknown)'
end select
enddo
end subroutine print_list

end program example_insert
59 changes: 59 additions & 0 deletions example/linked_list/example_linked_pop.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
! example_pop.f90 --
! Demonstrate the pop method
!
program example_pop
use stdlib_linked_list

implicit none

type(linked_list_type) :: list

!
! Add a few elements
!
call list%insert( "String element", 1 )
call list%insert( 2, 2 )
call list%insert( 3.3, 3 )

call print_list( list )

!
! Now pop the last element from the list
!

call list%pop

!
! Print the list
!
write(*,*) 'New list:'
call print_list( list )

contains
!include 'linked_list_aux.inc'
subroutine print_list( list )
type(linked_list_type), intent(in) :: list

integer :: i
class(*), pointer :: list_item

do i = 1,list%size()
list_item => list%get(i)

select type( item => list_item )
type is (integer)
write(*,*) i, item, ' (integer)'

type is (real)
write(*,*) i, item, ' (real)'

type is (character(*))
write(*,*) i, ' >', item, '< (string)'

class default
write(*,*) i, ' (type unknown)'
end select
enddo
end subroutine print_list

end program example_pop
Loading
Loading