{"id":15971890,"url":"https://github.com/kputnam/cantor","last_synced_at":"2025-03-17T22:30:49.315Z","repository":{"id":62355196,"uuid":"166894557","full_name":"kputnam/cantor","owner":"kputnam","description":"Fast implementation of finite and complement sets in Ruby","archived":false,"fork":false,"pushed_at":"2019-01-22T03:35:52.000Z","size":16,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-22T13:36:05.050Z","etag":null,"topics":["ruby","sets"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":false,"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/kputnam.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-01-21T23:26:37.000Z","updated_at":"2024-11-10T17:09:46.000Z","dependencies_parsed_at":"2022-10-31T10:50:29.904Z","dependency_job_id":null,"html_url":"https://github.com/kputnam/cantor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kputnam%2Fcantor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kputnam%2Fcantor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kputnam%2Fcantor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kputnam%2Fcantor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kputnam","download_url":"https://codeload.github.com/kputnam/cantor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243886570,"owners_count":20363756,"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":["ruby","sets"],"created_at":"2024-10-07T20:41:04.283Z","updated_at":"2025-03-17T22:30:49.010Z","avatar_url":"https://github.com/kputnam.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cantor [![Build Status](https://secure.travis-ci.org/kputnam/cantor.png)](http://travis-ci.org/kputnam/cantor)\n\nFast implementation of finite and complement sets in Ruby\n\n## Constructors\n\n##### `Cantor.empty`\nFinite set that contains no elements\n\n##### `Cantor.build(enum)`\nFinite set containing each element in `enum`, whose domain of discourse\nis unrestricted\n\n##### `Cantor.absolute(enum, universe)`\nFinite set containing each element in `enum`, whose domain of discourse\nis `universe`\n\n##### `Cantor.universal`\nInfinite set containing every value in the universe\n\n##### `Cantor.complement(enum)`\nSet containing every value except those in `enum`. Finite when `enum` is\ninfinite. Infinite when `enum` is finite\n\n## Operations\n\n* `xs.include?(x)`\n* `xs.exclude?(x)`\n* `xs.finite?`\n* `xs.infinite?`\n* `xs.empty?`\n* `xs.size`\n* `xs.replace(ys)`\n* `~xs`\n* `xs.complement`\n* `xs + xs`\n* `xs | ys`\n* `xs.union(ys)`\n* `xs - ys`\n* `xs.difference(ys)`\n* `xs ^ ys`\n* `xs.symmetric_difference(ys)`\n* `xs \u0026 ys`\n* `xs.intersection(ys)`\n* `xs \u003c= ys`\n* `xs.subset?(ys)`\n* `xs \u003c ys`\n* `xs.proper_subset?(ys)`\n* `xs \u003e= ys`\n* `xs.superset?(ys)`\n* `xs \u003e ys`\n* `xs.proper_superset?(ys)`\n* `xs.disjoint?(ys)`\n* `xs == ys`\n\n## Performance\n\nSets with a finite domain of discourse are represented using a bit string of\n2\u003csup\u003eU\u003c/sup\u003e bits, where U is the size of the domain. This provides nearly\nO(1) constant-time implementation using bitwise operations for all of the above\nset operations.\n\nThe bit string is represented as an Integer, but as the domain grows larger\nthan `0.size * 8 - 2` items, the type is automatically expanded to a Bignum.\nBitwise operations on Bignums are O(U), which is still be significantly\nfaster than using the default Set library.\n\nSets with an unrestricted domain of discourse are implemented using a Hash.\nUnary operations and membership tests are O(1) constant-time. Binary operations\non these sets is close to that of the default Set library.\n\n\u003c!--\n### Benchmarks\n\nThese benchmarks aren't intended to be useful. While they indicate the\nworst-case performance for Cantor, they probably don't show the worst\ncase for the standard Set library.\n\nNote \"Relative\" indicates Cantor sets with an infinite domain of discourse.\nThis includes `Cantor.build`, `Cantor.universal`, and `Cantor.complement`.\n\"Absolute\" sets are Cantor sets with a finite domain of discourse, built\nfrom `Cantor.absolute`.\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003cimg title=\"intersection\" src=\"/benchmark/intersection.png\"/\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003cimg title=\"difference\" src=\"/benchmark/difference.png\"/\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003cimg title=\"union\" src=\"/benchmark/union.png\"/\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003cimg title=\"symmetric difference\" src=\"/benchmark/sdifference.png\"/\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003cimg title=\"subset\" src=\"/benchmark/subset.png\"/\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003cimg title=\"superset\" src=\"/benchmark/superset.png\"/\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003cimg title=\"equality\" src=\"/benchmark/equality.png\"/\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003cimg title=\"membership\" src=\"/benchmark/membership.png\"/\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkputnam%2Fcantor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkputnam%2Fcantor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkputnam%2Fcantor/lists"}