A simple unoptimized integer set for fortran.
program tutorial use,intrinsic:: iso_c_binding use:: integer32_setimplicit none type(int32_set):: my_setinteger(c_int32_t):: i ! Ensure that you create the memory for the set using this built-in method. my_set= new_int32_set() ! Let us add somedata, backwards.do i=10,1,-1call my_set%push(i)end doprint*,"size:",my_set%size ! Now let us push it backin forwards.do i=1,10call my_set%push(i)end do ! The size is still10.print*,"size:",my_set%sizeprint*,my_set%data ! We can get itto go from min->max using the sort method.call my_set%sort()print*,"size:",my_set%sizeprint*,my_set%data ! Suppose we wantto remove the even numbers.do i=0,10,2call my_set%pop(i)end doprint*,"size:",my_set%size ! Tada.print*,my_set%data !! Don not forgetto destroy the memory. :)call my_set%destroy() ! Which will give you a size of-1.print*,my_set%size ! Andthen you just use the new_int32_set functionto re-use the variable. ! Using int64_set is literally the same, but you are using c_int64_t.end program tutorial