{"id":22769718,"url":"https://github.com/bfontaine/sparse","last_synced_at":"2025-03-30T11:29:30.716Z","repository":{"id":34616284,"uuid":"38565133","full_name":"bfontaine/sparse","owner":"bfontaine","description":":ant: Golang library for memory-efficient sparse data structures","archived":false,"fork":false,"pushed_at":"2015-07-05T13:32:58.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T23:43:41.825Z","etag":null,"topics":["go","library","sparse-data"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/bfontaine/sparse","language":"Go","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/bfontaine.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":"2015-07-05T10:27:14.000Z","updated_at":"2025-02-20T07:45:28.000Z","dependencies_parsed_at":"2022-07-15T17:30:29.618Z","dependency_job_id":null,"html_url":"https://github.com/bfontaine/sparse","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/bfontaine%2Fsparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fsparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fsparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fsparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bfontaine","download_url":"https://codeload.github.com/bfontaine/sparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246313054,"owners_count":20757421,"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":["go","library","sparse-data"],"created_at":"2024-12-11T15:14:29.370Z","updated_at":"2025-03-30T11:29:30.683Z","avatar_url":"https://github.com/bfontaine.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sparse\n\n**sparse** is a Go library for memory-efficient and thread-safe sparse data\nstructures.\n\n[![Build Status](https://travis-ci.org/bfontaine/sparse.svg?branch=master)](https://travis-ci.org/bfontaine/sparse)\n[![GoDoc](https://godoc.org/github.com/bfontaine/sparse?status.svg)](https://godoc.org/github.com/bfontaine/sparse)\n\n## Install\n\n    go get github.com/bfontaine/sparse\n\n## Content\n\nOnly two data structures are provided for now:\n\n* `BoolSlice` is a compact representation of `[]bool`\n* `BoolMatrix` is based on `BoolSlice` to provide a compact representation of a\n  booleans matrix\n\nThese data structures are more efficient in memory but less efficient in time.\nRead operations on both are in `O(n)` even if in practice they’re much lower if\nthe structures contain sparse data. The write operations are costly due to the\ninternal data representation. You shouldn’t use these if you want small slices\nwith frequent write access. They become practical with large data structures\nconsisting of *sparse* data.\n\nFor example, consider a slice of 1M `false` values with only 1000 `true`\nvalues in it. A normal `bool` slice will need 1M cells while a `BoolSlice` will\nuse between 2 and 2001 cells depending on where the `true` values are. Append\nanother 1M false values: the `bool` slice will double its size while the\n`BoolSlice` internal size won’t change.\n\n## Internal representation\n\nA `BoolSlice` has an internal `int64` slice `m` representing the contiguous\nsequences of boolean values. The first sequence is always `false` by\nconvention. Each cell of `m` contains the length of a contiguous sequence.\n\nExamples:\n\n| content              | `m`             |\n|----------------------|-----------------|\n| `[]`                 | `[]`            |\n| `[F]`                | `[1]`           |\n| `[F, F, F]`          | `[3]`           |\n| `[F, F, T]`          | `[2, 1]`        |\n| `[T, T]`             | `[0, 2]`        |\n| `[F, F, T, F, F, F]` | `[2, 1, 3]`     |\n| `[T, 20 × F, T]`     | `[0, 1, 20, 1]` |\n\n\n## Limitations\n\n* The `Set` method isn’t supported at the moment. This means the only way to\n  write on a `BoolSlice` after its initialization is with `.Append`.\n  I’m looking for an efficient *and* elegant way to solve this issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfontaine%2Fsparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbfontaine%2Fsparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfontaine%2Fsparse/lists"}