@@ -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
@@ -736,16 +739,16 @@ pure function get_string_idx_impl( list, idx )
736
739
737
740
end function get_string_idx_impl
738
741
739
- ! delete :
742
+ ! pop :
740
743
741
744
! > Version: experimental
742
745
! >
743
- ! > Deletes the string present at stringlist_index 'idx' in stringlist 'list'
744
- ! > Returns the deleted string
745
- impure function delete_string_idx_impl ( list , idx )
746
+ ! > Removes the string present at stringlist_index 'idx' in stringlist 'list'
747
+ ! > Returns the removed string
748
+ function pop_string_idx_impl ( list , idx )
746
749
class(stringlist_type) :: list
747
750
type (stringlist_index_type), intent (in ) :: idx
748
- type (string_type) :: delete_string_idx_impl
751
+ type (string_type) :: pop_string_idx_impl
749
752
750
753
integer :: idxn, i, inew
751
754
integer :: old_len, new_len
@@ -757,7 +760,7 @@ impure function delete_string_idx_impl( list, idx )
757
760
! if the index is out of bounds, returns a string_type instance equivalent to empty string
758
761
! without deleting anything from the stringlist
759
762
if ( 1 <= idxn .and. idxn <= old_len ) then
760
- delete_string_idx_impl = list% stringarray(idxn)
763
+ pop_string_idx_impl = list% stringarray(idxn)
761
764
762
765
new_len = old_len - 1
763
766
@@ -775,6 +778,22 @@ impure function delete_string_idx_impl( list, idx )
775
778
776
779
end if
777
780
778
- end function delete_string_idx_impl
781
+ end function pop_string_idx_impl
782
+
783
+ ! drop:
784
+
785
+ ! > Version: experimental
786
+ ! >
787
+ ! > Removes the string present at stringlist_index 'idx' in stringlist 'list'
788
+ ! > Doesn't return the removed string
789
+ subroutine drop_string_idx_impl ( list , idx )
790
+ class(stringlist_type) :: list
791
+ type (stringlist_index_type), intent (in ) :: idx
792
+ type (string_type) :: garbage_string
793
+
794
+ ! Throwing away garbage_string by not returning it
795
+ garbage_string = list% pop( idx )
796
+
797
+ end subroutine drop_string_idx_impl
779
798
780
799
end module stdlib_stringlist_type
0 commit comments