Skip to content

pop, drop & get with basic range feature for stringlist #514

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

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
933a367
resolved inserting 0 lengthed slist in list bug
aman-godara Oct 10, 2021
ea46f19
changed name
aman-godara Oct 10, 2021
c790494
added delete function for stringlist
aman-godara Sep 6, 2021
e446e7a
completed TODO by adding move subroutine
aman-godara Sep 6, 2021
bfad13d
renamed delete to pop, created subroutine drop
aman-godara Sep 12, 2021
00de2b7
fixed an error in documentation of stringlist
aman-godara Sep 12, 2021
92d5f0d
created a new subroutine pop_positions
aman-godara Sep 12, 2021
1468fb6
added range functions for pop and drop
aman-godara Sep 12, 2021
937fac2
corrected a typo
aman-godara Sep 12, 2021
f60dd9e
corrected errors in documentation
aman-godara Sep 13, 2021
88a1abb
added range feature for get, added shift function
aman-godara Sep 13, 2021
ccd6dff
made move subroutine of stdlib_string_type module pure
aman-godara Sep 13, 2021
2e216c8
some minor changes
aman-godara Sep 15, 2021
5d24c0c
rename capture_popped to popped_strings
aman-godara Sep 17, 2021
48c94dc
renamed to popped_strings all over the function
aman-godara Sep 17, 2021
980c18a
removing redundant naming convention
aman-godara Sep 26, 2021
e935ea1
improved append operator's performance
aman-godara Sep 26, 2021
e34cce2
changed naming convention throughout the module
aman-godara Sep 26, 2021
2b3a5ef
some minor improvements
aman-godara Oct 15, 2021
29f9880
Minor refactoring
aman-godara Dec 25, 2021
207c1fb
Add strides feature to get function
aman-godara Dec 26, 2021
e6b6143
Add get_impl interface in the middle
aman-godara Dec 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added range functions for pop and drop
  • Loading branch information
aman-godara committed Oct 15, 2021
commit 1468fb6765b4e44450d7b75450a9dc945a0100de
77 changes: 56 additions & 21 deletions src/stdlib_stringlist_type.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ module stdlib_stringlist_type
procedure :: insert_at_stringlist_idx => insert_at_stringlist_idx_wrap
procedure :: insert_at_chararray_idx => insert_at_chararray_idx_wrap
procedure :: insert_at_stringarray_idx => insert_at_stringarray_idx_wrap
generic, public :: insert_at => insert_at_char_idx, &
insert_at_string_idx, &
insert_at_stringlist_idx, &
insert_at_chararray_idx, &
generic, public :: insert_at => insert_at_char_idx, &
insert_at_string_idx, &
insert_at_stringlist_idx, &
insert_at_chararray_idx, &
insert_at_stringarray_idx

procedure :: insert_before_string_int => insert_before_string_int_impl
Expand All @@ -87,11 +87,15 @@ module stdlib_stringlist_type
procedure :: get_string_idx => get_string_idx_impl
generic, public :: get => get_string_idx

procedure :: pop_string_idx => pop_string_idx_impl
generic, public :: pop => pop_string_idx
procedure :: pop_idx => pop_idx_impl
procedure :: pop_range_idx => pop_range_idx_impl
generic, public :: pop => pop_idx, &
pop_range_idx

procedure :: drop_string_idx => drop_string_idx_impl
generic, public :: drop => drop_string_idx
procedure :: drop_idx => drop_idx_impl
procedure :: drop_range_idx => drop_range_idx_impl
generic, public :: drop => drop_idx, &
drop_range_idx

end type stringlist_type

Expand Down Expand Up @@ -743,7 +747,7 @@ end function get_string_idx_impl
!>
!> Removes strings present at indexes in interval ['first', 'last']
!> Returns captured popped strings
subroutine pop_positions( list, first, last, capture_popped)
subroutine pop_engine( list, first, last, capture_popped)
class(stringlist_type) :: list
type(stringlist_index_type), intent(in) :: first, last
type(string_type), allocatable, intent(out), optional :: capture_popped(:)
Expand Down Expand Up @@ -785,44 +789,75 @@ subroutine pop_positions( list, first, last, capture_popped)
end do

call move_alloc( new_stringarray, list%stringarray )

else
if ( present(capture_popped) ) then
allocate( capture_popped(0) )
end if
end if

end subroutine pop_positions
end subroutine pop_engine

! pop:

!> Version: experimental
!>
!> Removes the string present at stringlist_index 'idx' in stringlist 'list'
!> Returns the removed string
function pop_string_idx_impl( list, idx )
function pop_idx_impl( list, idx )
class(stringlist_type) :: list
type(stringlist_index_type), intent(in) :: idx
type(string_type) :: pop_string_idx_impl
type(string_type) :: pop_idx_impl

type(string_type), dimension(:), allocatable :: capture_popped
type(string_type), dimension(:), allocatable :: popped_strings

call pop_positions( list, idx, idx, capture_popped )
call pop_engine( list, idx, idx, popped_strings )

if ( allocated(capture_popped) ) then
pop_string_idx_impl = capture_popped(1)
if ( size(popped_strings) > 0 ) then
pop_idx_impl = popped_strings(1)
end if

end function pop_string_idx_impl
end function pop_idx_impl

!> Version: experimental
!>
!> Removes strings present at stringlist_indexes in interval ['first', 'last']
!> in stringlist 'list'
!> Returns removed strings
function pop_range_idx_impl( list, first, last )
class(stringlist_type) :: list
type(stringlist_index_type), intent(in) :: first, last

type(string_type), dimension(:), allocatable :: pop_range_idx_impl

call pop_engine( list, first, last, pop_range_idx_impl )

end function pop_range_idx_impl

! drop:

!> Version: experimental
!>
!> Removes the string present at stringlist_index 'idx' in stringlist 'list'
!> Doesn't return the removed string
subroutine drop_string_idx_impl( list, idx )
subroutine drop_idx_impl( list, idx )
class(stringlist_type) :: list
type(stringlist_index_type), intent(in) :: idx

call pop_positions( list, idx, idx )
call pop_engine( list, idx, idx )

end subroutine drop_idx_impl

!> Version: experimental
!>
!> Removes strings present at stringlist_indexes in interval ['first', 'last']
!> in stringlist 'list'
!> Doesn't return removed strings
subroutine drop_idx_impl( list, first, last)
class(stringlist_type) :: list
type(stringlist_index_type), intent(in) :: first, last

call pop_engine( list, first, last )

end subroutine drop_string_idx_impl
end subroutine drop_idx_impl

end module stdlib_stringlist_type
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy