Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CStack.f90 1.0 KiB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. module CStack
  2. use CPath
  3. implicit none
  4. public
  5. type, public :: Stack
  6. type(Path) :: List
  7. contains
  8. procedure :: Clear => Clear
  9. procedure :: Push => Push
  10. procedure :: Pop => Pop
  11. procedure :: DoesHave => DoesHave
  12. end type Stack
  13. contains
  14. subroutine Clear(this)
  15. implicit none
  16. class(Stack), intent(inout) :: this
  17. call this%List%MakeNull()
  18. end subroutine
  19. subroutine Push(this, value)
  20. implicit none
  21. class(Stack), intent(inout) :: this
  22. integer, intent(in) :: value
  23. call this%List%Add(value)
  24. end subroutine
  25. subroutine Pop(this)
  26. implicit none
  27. class(Stack), intent(inout) :: this
  28. call this%List%Remove(this%List%Length())
  29. end subroutine
  30. logical function DoesHave(this, value)
  31. implicit none
  32. class(Stack), intent(in) :: this
  33. integer, intent(in) :: value
  34. DoesHave = this%List%Find(value)
  35. end function
  36. end module CStack