Skip to content

Euler-37/fortran_vector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

fortran vector_int

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published