@@ -87,8 +87,11 @@ module stdlib_stringlist_type
8787 procedure :: get_string_idx = > get_string_idx_impl
8888 generic, public :: get = > get_string_idx
8989
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
9295
9396 end type stringlist_type
9497
@@ -736,16 +739,16 @@ pure function get_string_idx_impl( list, idx )
736739
737740 end function get_string_idx_impl
738741
739- ! delete :
742+ ! pop :
740743
741744 ! > Version: experimental
742745 ! >
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 )
746749 class(stringlist_type) :: list
747750 type (stringlist_index_type), intent (in ) :: idx
748- type (string_type) :: delete_string_idx_impl
751+ type (string_type) :: pop_string_idx_impl
749752
750753 integer :: idxn, i, inew
751754 integer :: old_len, new_len
@@ -757,7 +760,7 @@ impure function delete_string_idx_impl( list, idx )
757760 ! if the index is out of bounds, returns a string_type instance equivalent to empty string
758761 ! without deleting anything from the stringlist
759762 if ( 1 <= idxn .and. idxn <= old_len ) then
760- delete_string_idx_impl = list% stringarray(idxn)
763+ pop_string_idx_impl = list% stringarray(idxn)
761764
762765 new_len = old_len - 1
763766
@@ -775,6 +778,22 @@ impure function delete_string_idx_impl( list, idx )
775778
776779 end if
777780
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
779798
780799end module stdlib_stringlist_type
0 commit comments