ivector_t Derived Type

type, public :: ivector_t


Inherited by

type~~ivector_t~~InheritedByGraph type~ivector_t ivector_t type~itable_t itable_t type~itable_t->type~ivector_t buffer

Contents

Source Code


Components

TypeVisibility AttributesNameInitial
integer, public :: len_init =8
integer, public :: len =0
integer, public :: len_max =16
integer, public, dimension(:), allocatable:: buffer

Type-Bound Procedures

procedure, public :: delete => ivector_delete

  • public subroutine ivector_delete(this)

    Deletes an ivector. No access is allowed to this object after this call.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this

procedure, public :: clear => ivector_clear

  • public subroutine ivector_clear(this)

    Clears an ivector. Access allowed after a call to clear.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this

procedure, public :: get_val => ivector_get_val

  • public function ivector_get_val(this, i) result(res)

    Returns the ith element of an ivector.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(in) :: this
    integer, intent(in) :: i

    Return Value integer

procedure, public :: set_val => ivector_set_val

  • public subroutine ivector_set_val(this, i, val)

    Sets the value of the ith element of an ivector. No bounds check is performed.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this
    integer, intent(in) :: i
    integer, intent(in) :: val

procedure, public :: get_data => ivector_get_data

  • public subroutine ivector_get_data(this, res, ibeg, iend)

    Returns a pointer to the underlying data of an ivector

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(in), target:: this
    integer, intent(out), dimension(:), pointer:: res
    integer, intent(in), optional :: ibeg
    integer, intent(in), optional :: iend

procedure, public :: append => ivector_append

  • public subroutine ivector_append(this, val)

    Adds an element to the end of an ivector. Reallocation will take place if required.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this
    integer, intent(in) :: val

procedure, public :: pop => ivector_pop

  • public function ivector_pop(this) result(val)

    Removes the last element and returns it. Calling this method on an empty list

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this

    Return Value integer

procedure, public :: resize => ivector_resize

  • public subroutine ivector_resize(this, new_size, ierr)

    Resizes a vector to a given size. Existing data is truncated if desired size is smaller than current size. Otherwise, the empty spaces are filled with zero.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this
    integer, intent(in) :: new_size
    integer, intent(out), optional :: ierr

procedure, public :: shrink_to_fit => ivector_shrink_to_fit

  • public subroutine ivector_shrink_to_fit(this, ierr)

    Releases additional memory to fit underlying data of an ivector to a size this%len_init.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this
    integer, intent(out), optional :: ierr

procedure, public :: sort => ivector_sort

  • public subroutine ivector_sort(this, order)

    Sorts an ivector in ascending order. If order is provided, it will contain the sorted indices. The size of order must be at least this%len.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this
    integer, intent(out), optional dimension(:):: order

procedure, public :: unique => ivector_unique

  • public subroutine ivector_unique(this)

    Sorts and removes all duplicate entries of an ivector. Note that the internal buffer size remains unchanged. To reduce the buffer size, call ivector_shrink_to_fit.

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(inout) :: this

procedure, public :: print => ivector_print

  • public subroutine ivector_print(this)

    Prints an ivector

    Arguments

    Type IntentOptional AttributesName
    class(ivector_t), intent(in) :: this

Source Code

type ivector_t
    integer :: len_init = 8 !Must be > 0
    integer :: len = 0
    integer :: len_max = 16 !Must be > len_init
    integer, dimension(:), allocatable :: buffer

    contains
        procedure :: delete => ivector_delete
        procedure :: clear => ivector_clear
        procedure :: get_val => ivector_get_val
        procedure :: set_val => ivector_set_val
        procedure :: get_data => ivector_get_data
        procedure :: append => ivector_append
        procedure :: pop => ivector_pop
        procedure :: resize => ivector_resize
        procedure :: shrink_to_fit => ivector_shrink_to_fit
        procedure :: sort => ivector_sort
        procedure :: unique => ivector_unique
        procedure :: print => ivector_print
end type ivector_t