! ÕâÀïÊµÏÖµÄnodeÀïÃæÖ»´æÁËÒ»¸öindex,²¢ÇÒÃ»ÓÐÐò
module node_class
private
    type node
        integer :: index_
        type(node), pointer :: next_ => null()
        type(node), pointer :: prev_ => null()
    end type node
    
    
    interface new
        module procedure new_this
    end interface
    
    interface operator( .EQ. )
        module procedure equal_this
    end interface

    interface operator( .LT. )
        module procedure less_this
    end interface
    
public node, new, operator(.EQ.), operator(.LT.)
    contains
    ! ÐÂ½¨Ö¸Õë
    subroutine new_this(this, index)
    type(node), pointer:: this
    integer :: index
    integer(4) :: err
        allocate(this, stat = err)
        this%index_  = index
    end subroutine new_this

    ! ÓÃÓÚÐÂ½¨operator .EQ.
    logical function equal_this(p_node1, p_node2)
    type(node), intent(in) :: p_node1, p_node2
        equal_this = p_node1%index_ .EQ. p_node2%index_
    end function equal_this
    
    ! ÓÃÓÚÐÂ½¨operator .LT.
    logical function less_this(p_node1, p_node2)
    type(node), pointer, intent(in) :: p_node1, p_node2
        less_this = p_node1%index_ .LT. p_node2%index_
    end function less_this
end module node_class