Simulation Core
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.1 KiB

  1. module CStack
  2. use CPath,Only:Path
  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