-
Notifications
You must be signed in to change notification settings - Fork 191
String list new #680
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
Open
arjenmarkus
wants to merge
24
commits into
fortran-lang:master
Choose a base branch
from
arjenmarkus:string-list-new
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
String list new #680
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
263a652
Add module for list of strings
arjenmarkus 90b06ff
Correct typo
arjenmarkus 4157ed1
Merge remote-tracking branch 'upstream/master' into string-list-new
arjenmarkus e36f997
Merge branch 'master' into string-list-new
arjenmarkus 024b078
Documentation and corrected source code for linked lists
arjenmarkus 4379fb4
Correct subdirectory for examples
arjenmarkus 3067b9a
Move the implementations of the linked_list modules to src
arjenmarkus 3cf3d85
Use an include statement to get the auxiliary subroutine in
arjenmarkus edd20fd
Use an internal routine instead for print_list
arjenmarkus 86d2fe4
Add a CMakeLists.txt for building the examples
arjenmarkus 327c8c1
Rename the examples to avoid conflicts
arjenmarkus 8f2f1fa
Define a new macro to take care of the include directory
arjenmarkus 09b7266
Adjust the CMake and CI build set-ups
arjenmarkus af8dd68
Rename the include file
arjenmarkus fae33a4
Correct the test program
arjenmarkus 41417f4
Update test_performance.f90
arjenmarkus b8c18ea
Create CMakeLists.txt file for performance test program
arjenmarkus ca684ae
Merge branch 'master' into string-list-new
jvdp1 5644454
Updated documentation and source code
arjenmarkus e23b1ea
Adjusting the examples and fixing an INTENT() error
arjenmarkus b5e41c1
Merge branch 'string-list-new' of https://github.com/arjenmarkus/stdl…
arjenmarkus ebb84b8
Add explicit include directory
arjenmarkus b310239
Incorporate the auxiliary routine directly
arjenmarkus 220791a
Correct the name of the test programs
arjenmarkus 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include_directories(${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
macro(ADD_EXAMPLE_INCLUDE name) | ||
add_executable(example_${name} example_${name}.f90) | ||
target_include_drectories(example_${name} ${CMAKE_CURRENT_SOURCE_DIR}) | ||
jvdp1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
target_link_libraries(example_${name} "${PROJECT_NAME}") | ||
add_test(NAME ${name} | ||
COMMAND $<TARGET_FILE:example_${name}> ${CMAKE_CURRENT_BINARY_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||
endmacro(ADD_EXAMPLE_INCLUDE) | ||
|
||
ADD_EXAMPLE_INCLUDE(linked_absorb) | ||
ADD_EXAMPLE_INCLUDE(linked_clear) | ||
ADD_EXAMPLE_INCLUDE(linked_concat) | ||
ADD_EXAMPLE_INCLUDE(linked_get) | ||
ADD_EXAMPLE_INCLUDE(linked_insert) | ||
ADD_EXAMPLE_INCLUDE(linked_pop) | ||
ADD_EXAMPLE_INCLUDE(linked_push) | ||
ADD_EXAMPLE_INCLUDE(linked_remove) | ||
ADD_EXAMPLE_INCLUDE(linked_replace) | ||
ADD_EXAMPLE_INCLUDE(linked_reverse) | ||
ADD_EXAMPLE_INCLUDE(linked_size) | ||
ADD_EXAMPLE_INCLUDE(linked_slice) | ||
ADD_EXAMPLE_INCLUDE(linked_splice) |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
! example_absorb.f90 -- | ||
! Demonstrate the absorb method | ||
! | ||
program example_absorb | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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.f90' | ||
|
||
end program example_absorb |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
! example_clear.f90 -- | ||
! Demonstrate the clear method | ||
! | ||
program example_clear | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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 |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
! example_concat.f90 -- | ||
! Demonstrate the concat method | ||
! | ||
program example_concat | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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.f90' | ||
|
||
end program example_concat |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
! example_get.f90 -- | ||
! Demonstrate the get method | ||
! | ||
program example_get | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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 |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
! example_insert.f90 -- | ||
! Demonstrate the insert method | ||
! | ||
|
||
program example_insert | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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.f90' | ||
|
||
end program example_insert |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
! example_pop.f90 -- | ||
! Demonstrate the pop method | ||
! | ||
program example_pop | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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.f90' | ||
|
||
end program example_pop |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
! example_push.f90 -- | ||
! Demonstrate the push method | ||
! | ||
program example_push | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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 push a new element to the end | ||
! | ||
|
||
call list%push( 3 ) | ||
|
||
! | ||
! Print the list | ||
! | ||
write(*,*) 'New list:' | ||
call print_list( list ) | ||
|
||
contains | ||
include 'linked_list_aux.f90' | ||
|
||
end program example_push |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
! example_remove.f90 -- | ||
! Demonstrate the remove method | ||
! | ||
program example_remove | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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 remove the second element | ||
! | ||
|
||
call list%remove( 2 ) | ||
|
||
! | ||
! Print the list | ||
! | ||
write(*,*) 'New list:' | ||
call print_list( list ) | ||
|
||
contains | ||
include 'linked_list_aux.f90' | ||
|
||
end program example_remove |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
! example_replace.f90 -- | ||
! Demonstrate the replace method | ||
! | ||
program example_replace | ||
use stdlib_linked_list | ||
|
||
implicit none | ||
|
||
type(linked_list) :: 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 replace the second element by a string | ||
! | ||
|
||
call list%replace( "Another string", 2 ) | ||
|
||
! | ||
! Print the list | ||
! | ||
write(*,*) 'New list:' | ||
call print_list( list ) | ||
|
||
contains | ||
include 'linked_list_aux.f90' | ||
|
||
end program example_replace |
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.