Skip to content

Latest commit

 

History

History
80 lines (72 loc) · 1.04 KB

README.md

File metadata and controls

80 lines (72 loc) · 1.04 KB

fortran_vector

fortran vector_int, the type defined as

type::vector_int
    integer,allocatable::x_(:)
    integer::num_
    integer::capacity_
end type vector_int

init

set dim

type(vector_int)::a
call a%init()
! or
!call a%init(22333)

append

append elements, value or array

call a%append(10)
call a%append([1,2,3,4])

size

return size of vector

  write(*,*)size(a)

pop

pop last element

  write(*,*)a%pop()

remove

remove all val

  !! a=[1,2,3,3,4]
  call a%remove(3)
  !! a=[1,2,4]

delete

delete i-th val

  !! a=[1,3,2,4,9]
  call a%delete(2)
  !! a=[1,2,4,9]

unique

remove duplicate elements

  !! a=[1,1,3,2,2,4,4,9,10]
  call a%unique()
  !! a=[1,3,2,4,9,10]

sort

sort vector

  !! a=[1,1,3,2,2,4,4,9,10]
  call a%sort()
  !! a=[1,1,2,2,3,4,4,9,10]

cut

cut Extra memory

  ! a%capacity_==a%num_
  call a%cut()

clear

deallocate

  call a%clear()