set_integer_int32 Function

private pure function set_integer_int32(V) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: V(:)

Return Value integer(kind=int32), allocatable, (:)


Contents

Source Code


Source Code

    pure function set_integer_int32 (V) result(res)
        integer (int32), intent(in) :: V(:)
        integer(int32), allocatable :: res(:)
        integer(int32) :: sorted(size(V)), previous
        type(buffer_int32_1D_t) :: buffer
        integer :: i

        sorted = V
        call sort(sorted)

        call buffer%init()
        if (size(sorted) > 0) then
            call buffer%push_back(sorted(1))
            previous = sorted(1)
        end if
        do i = 2, size(sorted)
            if (previous /= sorted(i)) then
                call buffer%push_back(sorted(i))
                previous = sorted(i)
            end if
        end do
        call buffer%dump_reset(res)
    end function set_integer_int32