@@ -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
@@ -732,16 +735,16 @@ pure function get_string_idx_impl( list, idx )
732735
733736 end function get_string_idx_impl
734737
735- ! delete :
738+ ! pop :
736739
737740 ! > Version: experimental
738741 ! >
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 )
742745 class(stringlist_type) :: list
743746 type (stringlist_index_type), intent (in ) :: idx
744- type (string_type) :: delete_string_idx_impl
747+ type (string_type) :: pop_string_idx_impl
745748
746749 integer :: idxn, i, inew
747750 integer :: old_len, new_len
@@ -753,7 +756,7 @@ impure function delete_string_idx_impl( list, idx )
753756 ! if the index is out of bounds, returns a string_type instance equivalent to empty string
754757 ! without deleting anything from the stringlist
755758 if ( 1 <= idxn .and. idxn <= old_len ) then
756- delete_string_idx_impl = list% stringarray(idxn)
759+ pop_string_idx_impl = list% stringarray(idxn)
757760
758761 new_len = old_len - 1
759762
@@ -771,6 +774,22 @@ impure function delete_string_idx_impl( list, idx )
771774
772775 end if
773776
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
775794
776795end module stdlib_stringlist_type
0 commit comments