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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
Original file line numberDiff line numberDiff 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
Original file line numberDiff line numberDiff 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)
Original file line numberDiff line numberDiff 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
Original file line numberDiff line numberDiff 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
Original file line numberDiff line numberDiff 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
Original file line numberDiff line numberDiff 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
Original file line numberDiff line numberDiff 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
Original file line numberDiff line numberDiff 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