{"id":32290961,"url":"https://github.com/pschiffmann/indexed-set.dart","last_synced_at":"2025-10-23T02:59:51.015Z","repository":{"id":56832965,"uuid":"104277386","full_name":"pschiffmann/indexed-set.dart","owner":"pschiffmann","description":"Provides an `IndexedSet` class, an implementation of `Set` that computes an index for each of its elements, and exposes this mapping through the `[]` operator.","archived":false,"fork":false,"pushed_at":"2018-11-10T19:40:19.000Z","size":53,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T02:59:45.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dartlang.org/packages/indexed_set","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pschiffmann.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-20T23:20:01.000Z","updated_at":"2019-09-26T06:00:11.000Z","dependencies_parsed_at":"2022-09-08T07:50:09.427Z","dependency_job_id":null,"html_url":"https://github.com/pschiffmann/indexed-set.dart","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pschiffmann/indexed-set.dart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffmann%2Findexed-set.dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffmann%2Findexed-set.dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffmann%2Findexed-set.dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffmann%2Findexed-set.dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pschiffmann","download_url":"https://codeload.github.com/pschiffmann/indexed-set.dart/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffmann%2Findexed-set.dart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280551637,"owners_count":26349597,"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","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-23T02:59:43.655Z","updated_at":"2025-10-23T02:59:51.010Z","avatar_url":"https://github.com/pschiffmann.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"Dart indexed set\n================\n\n[![Build Status](https://travis-ci.com/pschiffmann/indexed-set.dart.svg?branch=master)](https://travis-ci.com/pschiffmann/indexed-set.dart)\n\nThis package provides an `IndexedSet` class, and a pair of `Superset`/`Subset` classes that implement the `IndexedSet` interface.\n\nIndexedSet\n----------\n\nAn `IndexedSet` adds a mapping mechanism to the `Set` interface.\nA user-provided function `I index(E element)` calculates an index for each element.\nThe elements are then accessible through the `[]` operator.\nThis allows you to define cleaner APIs than if you used a `Map`, because the data structure can enforce integrity of the key/value mapping.\n\n```dart\nenum System { frontend, backend }\n\nclass Account {\n  final String name;\n  final System system;\n\n  Account(this.name, this.system);\n\n  String toString() =\u003e '$system-account of $name';\n}\n\n/// Supports lookup of accounts by username.\nfinal frontendAccounts = new IndexedSet\u003cString, Account\u003e(\n    (Account acc) =\u003e acc.name,\n    isValidElement: (Account acc) =\u003e acc.system == System.frontend);\n```\n\nSuperset / Subset\n-----------------\n\nBoth `Superset` and `Subset` are indexed sets that use `int` as the index type.\nA Superset is immutable and stores its elements in ascending order -- the first element will have index `0`, the last element index `set.length - 1`.\nA Subset has to be taken from a superset, and can only contain elements that are also contained in the superset.\n\nThe idea was that subsets could store their elements in a bit vector, which would be very space-efficient, and time-efficient for set operations (difference, intersection, union) on subsets of the same superset. However, `Subset` is outperformed by a regular `HashSet` in most situations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpschiffmann%2Findexed-set.dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpschiffmann%2Findexed-set.dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpschiffmann%2Findexed-set.dart/lists"}