{"id":18733481,"url":"https://github.com/queryverse/iteratorinterfaceextensions.jl","last_synced_at":"2025-04-12T18:31:40.309Z","repository":{"id":61798387,"uuid":"107833695","full_name":"queryverse/IteratorInterfaceExtensions.jl","owner":"queryverse","description":"Traits for julia iterators","archived":false,"fork":false,"pushed_at":"2020-08-22T07:40:45.000Z","size":198,"stargazers_count":11,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T12:51:13.715Z","etag":null,"topics":["julia","queryverse"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/queryverse.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}},"created_at":"2017-10-22T03:14:48.000Z","updated_at":"2024-03-29T19:58:48.000Z","dependencies_parsed_at":"2022-10-21T11:15:28.123Z","dependency_job_id":null,"html_url":"https://github.com/queryverse/IteratorInterfaceExtensions.jl","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queryverse%2FIteratorInterfaceExtensions.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queryverse%2FIteratorInterfaceExtensions.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queryverse%2FIteratorInterfaceExtensions.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queryverse%2FIteratorInterfaceExtensions.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/queryverse","download_url":"https://codeload.github.com/queryverse/IteratorInterfaceExtensions.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248613503,"owners_count":21133524,"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":["julia","queryverse"],"created_at":"2024-11-07T15:09:55.660Z","updated_at":"2025-04-12T18:31:40.012Z","avatar_url":"https://github.com/queryverse.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IteratorInterfaceExtensions\n\n[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n[![Build Status](https://travis-ci.org/queryverse/IteratorInterfaceExtensions.jl.svg?branch=master)](https://travis-ci.org/queryverse/IteratorInterfaceExtensions.jl)\n[![Build status](https://ci.appveyor.com/api/projects/status/4rq8seb3j1wd7wpp/branch/master?svg=true)](https://ci.appveyor.com/project/queryverse/iteratorinterfaceextensions-jl/branch/master)\n[![codecov.io](http://codecov.io/github/queryverse/IteratorInterfaceExtensions.jl/coverage.svg?branch=master)](http://codecov.io/github/queryverse/IteratorInterfaceExtensions.jl?branch=master)\n\nIteratorInterfaceExtensions defines a small number of extensions to the iterator interface.\n\n## Overview\n\nThis package adds a couple of extensions to the standard [iterator interface](https://docs.julialang.org/en/latest/manual/interfaces/#man-interface-iteration-1) in julia.\n\n### ``isiterable`` and ``getiterator``\n\nThe first extension is comprised of the functions ``isiterable`` and ``getiterator``. ``isiterable(x)`` will return ``true`` or ``false``, indicating whether ``x`` can be iterated. It is important to note that a ``true`` return value does *not* indicate that one can call the ``iterate`` method on ``x``, instead a consumer *must* call ``getiterator(x)`` if ``isiterable(x)`` returned ``true``, and can then call ``iterate`` on the instance that is returned by ``getiterator``. The proper pattern for consumer code therefore looks like this:\n\n````julia\nif isiterable(x)\n    it = getiterator(x)\n    for i in it\n        # Custom code\n    end\nend\n````\nThis consumer pattern will work with iterators that don't opt into the extensions in this package and with iterators that have opted into the extended interface defined in this package.\n\nThere are two scenarios when a source might participate in this extended iterator interface.\n\nThe first scenario is one where a source could not implement a type-stable version of ``iterate`` because the primary source type lacks the necessary type information. Such a source can add a method to ``getiterator`` that returns an instance of a different type with enough type information for a type stable implementation of the core iterator interface that iterates the elements of the original source.\n\nSecond, sometimes such a source might not want to implement the ``iterate`` method at all for its core type. If that is the case, this source can add a method to ``isiterable`` that returns ``true``, even though the source does not have a ``iterate`` method. As long as this source still implements the ``getiterator`` function, it still complies with the extended iterator contract defined in this package.\n\n### ``IteratorSize2``\n\n``IteratorSize2`` extends ``Base.IteratorSize`` with an additional return value, namely ``HasLengthAfterStart()``. An iterator consumer that can provide an optimized implementation for iterators that know their length after the first call to the ``iterate`` method has, can call ``IteratorSize2`` instead of ``Base.IteratorSize``. The return value will either be one of the possible return values of ``Base.IteratorSize``, or ``HasLengthAfterStart()``. If the return value is ``HasLengthAfterStart()``, the consumer can call ``length(x, state)`` to obtain the number of elements the iterator will return. Here ``x`` is the same value that ``iterate`` was called on, and ``state`` is the value returned by\n``iterate(x)``.\n\nAn iterator that implements ``IteratorSize2(x::MyType) = HasLengthAfterStart()`` must also implement ``Base.IteratorSize(x::MyType) = Base.SizeUnknown()``.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueryverse%2Fiteratorinterfaceextensions.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqueryverse%2Fiteratorinterfaceextensions.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueryverse%2Fiteratorinterfaceextensions.jl/lists"}