{"id":25854780,"url":"https://github.com/jchristopherson/collections","last_synced_at":"2026-02-13T13:39:28.774Z","repository":{"id":94680802,"uuid":"569769140","full_name":"jchristopherson/collections","owner":"jchristopherson","description":"A set of types supporting collections in Fortran.","archived":false,"fork":false,"pushed_at":"2024-02-28T21:44:13.000Z","size":278,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-22T11:11:51.788Z","etag":null,"topics":["collection","collections","fortran","generic-collections","generic-list","linked-list","list","lists"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jchristopherson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-11-23T15:15:44.000Z","updated_at":"2023-08-15T16:42:38.000Z","dependencies_parsed_at":"2024-01-16T12:48:41.198Z","dependency_job_id":"2b3308e2-f9db-4184-8c5f-ef4b264a8c9d","html_url":"https://github.com/jchristopherson/collections","commit_stats":{"total_commits":54,"total_committers":1,"mean_commits":54.0,"dds":0.0,"last_synced_commit":"775d0e93a68b39e415f2d8523e0b0aa1e97c3835"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fcollections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fcollections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fcollections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristopherson%2Fcollections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jchristopherson","download_url":"https://codeload.github.com/jchristopherson/collections/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241389134,"owners_count":19955107,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collection","collections","fortran","generic-collections","generic-list","linked-list","list","lists"],"created_at":"2025-03-01T16:18:08.209Z","updated_at":"2026-02-13T13:39:23.745Z","avatar_url":"https://github.com/jchristopherson.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# collections\nA set of types supporting collections in Fortran.  Currently, the library contains a generic, dynamically sizable list and a generic linked-list type.\n\n## Description\nThe collections library contains generic and dynamically sizeable collection types using unlimited polymorphic types with an object-oriented design.\n\n## Build\n[CMake](https://cmake.org/) is the preferred build system for this library.  See [Running CMake](https://cmake.org/runningcmake/) for instructions on how to build using CMake.\n\n[FPM](https://github.com/fortran-lang/fpm) can also be used to build this library using the provided fpm.toml.\n```txt\nfpm build\n```\nThe COLLECTIONS library can be used within your FPM project by adding the following to your fpm.toml file.\n```\n[dependencies]\ncollections = { git = \"https://github.com/jchristopherson/collections\" }\n```\n\n## Dependencies\nThis library depends upon the [FERROR](https://github.com/jchristopherson/ferror) library.\n\n## Documentation\nThe documentation can be found [here](https://jchristopherson.github.io/collections/).\n\n## Examples\nThe collections library provides a generic, dynamically sizeable type referred to simply as list.  A simple example illustrating basic usage of the list type is as follows.\n```fortran\nprogram list_example\n    use collections\n    use iso_fortran_env\n    implicit none\n\n    ! Variables\n    integer(int32), parameter :: n = 10\n    integer(int32) :: i\n    type(list) :: x\n    class(*), pointer :: ptr\n\n    ! Create a list\n    do i = 1, n\n        call x%push(2 * i)\n    end do\n\n    ! Print it out to the command line\n    print '(A)', \"***** Original List *****\"\n    do i = 1, n\n        ptr =\u003e x%get(i)\n        \n        ! The list uses unlimited polymorphic types; therefore, we need to\n        ! use the select type construct.\n        select type (ptr)\n        type is (integer(int32))\n            print *, ptr\n        end select\n    end do\n\n    ! Insert the integer value of 100 into the 5th slot in the list\n    call x%insert(5, 100)\n\n    ! Print it out again to illustrate the change\n    print '(A)', new_line('a') // \"***** After Insertion *****\"\n    do i = 1, x%count()\n        ptr =\u003e x%get(i)\n        select type (ptr)\n        type is (integer(int32))\n            print *, ptr\n        end select\n    end do\nend program\n```\nThis program generates the following output.\n```\n***** Original List *****\n           2\n           4\n           6\n           8\n          10\n          12\n          14\n          16\n          18\n          20\n\n***** After Insertion *****\n           2\n           4\n           6\n           8\n         100\n          10\n          12\n          14\n          16\n          18\n          20\n```\nThe collections library also provides a generic linked-list type.  A simple example illustrating basic usage of the linked-list type is as follows.\n```fortran\nprogram linked_list_example\n    use collections\n    use iso_fortran_env\n    implicit none\n\n    ! Variables\n    integer(int32), parameter :: n = 10\n    integer(int32) :: i\n    logical :: check\n    type(linked_list) :: x\n    class(*), pointer :: ptr\n\n    ! Create a list\n    do i = 1, n\n        call x%push(i)\n    end do\n\n    ! Print it out\n    print '(A)', \"***** Original List *****\"\n    check = associated(x%get())\n    do while (check)\n        ptr =\u003e x%get()\n\n        ! The list uses unlimited polymorphic types; therefore, we need to\n        ! use the select type construct.\n        select type (ptr)\n        type is (integer(int32))\n            print *, ptr\n        end select\n\n        ! Move to the next item\n        check = x%next()\n    end do\n\n    ! Print out the item at the current iterator position\n    print '(A)', new_line('a') // \"***** Current Iterator Position *****\"\n    ptr =\u003e x%get()\n    select type(ptr)\n    type is (integer(int32))\n        print *, ptr\n    end select\n\n    ! Move to the beginning of the collection\n    print '(A)', new_line('a') // \"***** Beginning *****\"\n    call x%move_to_first()\n    ptr =\u003e x%get()\n    select type (ptr)\n    type is (integer(int32))\n        print *, ptr\n    end select\nend program\n```\nThis program generates the following output.\n```\n***** Original List *****\n           1\n           2\n           3\n           4\n           5\n           6\n           7\n           8\n           9\n          10\n\n***** Current Iterator Position *****\n          10\n\n***** Beginning *****\n           1\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristopherson%2Fcollections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjchristopherson%2Fcollections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristopherson%2Fcollections/lists"}