Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Development v1.2 #2

Merged
merged 22 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Work in progress for a linked list type
  • Loading branch information
jchristopherson committed Mar 19, 2021
commit 6ad7eb7ac95ccced59ee630835292ddef243175f
50 changes: 50 additions & 0 deletions src/collections.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ module collections
class(*), pointer :: item => null()
end type

!> @brief A node in a linked list container.
type node
!> A pointer to a polymorphic variable allowing storage of any type.
class(*), pointer :: item => null()
!> A pointer to the next node in the collection.
type(node), pointer :: next => null()
!> A pointer to the previous node in the collection.
type(node), pointer :: previous => null()
end type

!> @brief Defines a generic list.
type list
private
Expand Down Expand Up @@ -130,6 +140,20 @@ module collections
procedure, public :: get => hc_get
end type

!> @brief Defines a generic linked-list container.
type linked_list
private
!> @brief The number of nodes in the container.
integer(int32) :: m_nodeCount = 0
!> @brief A pointer to the first node in the container.
type(node), pointer :: m_first => null()
!> @brief A pointer to the last node in the container.
type(node), pointer :: m_last => null()
!> @brief A pointer to the current node. - for iteration purposes
type(node), pointer :: m_current => null()
contains
end type

! ******************************************************************************
! FUNCTION PROTOTYPES
! ------------------------------------------------------------------------------
Expand Down Expand Up @@ -345,5 +369,31 @@ module function hc_get(this, str) result(rst)
end function
end interface

! ------------------------------------------------------------------------------
interface ! collections_linked_list.f90
module subroutine lnk_clear(this)
class(linked_list), intent(inout) :: this
end subroutine

module subroutine lnk_push(this, x, err)
class(linked_list), intent(inout) :: this
class(*), intent(in) :: x
class(errors), intent(inout), optional, target :: err
end subroutine

module subroutine lnk_pop(this)
class(linked_list), intent(inout) :: this
end subroutine

! push
! pop
! move to first
! move to last
! next
! previous
! count
! get a pointer to the current object
end interface

! ------------------------------------------------------------------------------
end module
5 changes: 5 additions & 0 deletions src/collections_linked_list.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
! collections_linked_list.f90

submodule (collections) collections_linked_list.f90
contains
end submodule