@@ -87,8 +87,11 @@ module stdlib_stringlist_type
87
87
procedure :: get_string_idx = > get_string_idx_impl
88
88
generic, public :: get = > get_string_idx
89
89
90
- procedure :: delete_string_idx = > delete_string_idx_impl
91
- generic, public :: delete = > delete_string_idx
90
+ procedure :: pop_string_idx = > pop_string_idx_impl
91
+ generic, public :: pop = > pop_string_idx
92
+
93
+ procedure :: drop_string_idx = > drop_string_idx_impl
94
+ generic, public :: drop = > drop_string_idx
92
95
93
96
end type stringlist_type
94
97
@@ -732,16 +735,16 @@ pure function get_string_idx_impl( list, idx )
732
735
733
736
end function get_string_idx_impl
734
737
735
- ! delete :
738
+ ! pop :
736
739
737
740
! > Version: experimental
738
741
! >
739
- ! > Deletes the string present at stringlist_index 'idx' in stringlist 'list'
740
- ! > Returns the deleted string
741
- impure function delete_string_idx_impl ( list , idx )
742
+ ! > Removes the string present at stringlist_index 'idx' in stringlist 'list'
743
+ ! > Returns the removed string
744
+ function pop_string_idx_impl ( list , idx )
742
745
class(stringlist_type) :: list
743
746
type (stringlist_index_type), intent (in ) :: idx
744
- type (string_type) :: delete_string_idx_impl
747
+ type (string_type) :: pop_string_idx_impl
745
748
746
749
integer :: idxn, i, inew
747
750
integer :: old_len, new_len
@@ -753,7 +756,7 @@ impure function delete_string_idx_impl( list, idx )
753
756
! if the index is out of bounds, returns a string_type instance equivalent to empty string
754
757
! without deleting anything from the stringlist
755
758
if ( 1 <= idxn .and. idxn <= old_len ) then
756
- delete_string_idx_impl = list% stringarray(idxn)
759
+ pop_string_idx_impl = list% stringarray(idxn)
757
760
758
761
new_len = old_len - 1
759
762
@@ -771,6 +774,22 @@ impure function delete_string_idx_impl( list, idx )
771
774
772
775
end if
773
776
774
- end function delete_string_idx_impl
777
+ end function pop_string_idx_impl
778
+
779
+ ! drop:
780
+
781
+ ! > Version: experimental
782
+ ! >
783
+ ! > Removes the string present at stringlist_index 'idx' in stringlist 'list'
784
+ ! > Doesn't return the removed string
785
+ subroutine drop_string_idx_impl ( list , idx )
786
+ class(stringlist_type) :: list
787
+ type (stringlist_index_type), intent (in ) :: idx
788
+ type (string_type) :: garbage_string
789
+
790
+ ! Throwing away garbage_string by not returning it
791
+ garbage_string = list% pop( idx )
792
+
793
+ end subroutine drop_string_idx_impl
775
794
776
795
end module stdlib_stringlist_type
0 commit comments