{"id":13411728,"url":"https://github.com/perdata/treap","last_synced_at":"2025-03-14T17:31:03.936Z","repository":{"id":57496803,"uuid":"148953747","full_name":"perdata/treap","owner":"perdata","description":"golang persistent immutable treap sorted sets","archived":false,"fork":false,"pushed_at":"2019-12-18T09:31:05.000Z","size":14,"stargazers_count":27,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T20:48:41.051Z","etag":null,"topics":["golang","heap","immutable","map","persistent","set","treap","tree"],"latest_commit_sha":null,"homepage":null,"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/perdata.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":"2018-09-16T01:38:03.000Z","updated_at":"2024-04-19T02:30:57.000Z","dependencies_parsed_at":"2022-08-28T19:50:27.937Z","dependency_job_id":null,"html_url":"https://github.com/perdata/treap","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/perdata%2Ftreap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perdata%2Ftreap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perdata%2Ftreap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perdata%2Ftreap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perdata","download_url":"https://codeload.github.com/perdata/treap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618657,"owners_count":20320272,"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":["golang","heap","immutable","map","persistent","set","treap","tree"],"created_at":"2024-07-30T20:01:16.268Z","updated_at":"2025-03-14T17:31:03.425Z","avatar_url":"https://github.com/perdata.png","language":"Go","funding_links":[],"categories":["Data Structures and Algorithms","数据结构","Data Structures","数据结构与算法","Generators","数据结构`go语言实现的数据结构与算法`","Uncategorized"],"sub_categories":["Trees","标准 CLI","Advanced Console UIs","树"],"readme":"# treap\n\n[![Status](https://travis-ci.com/perdata/treap.svg?branch=master)](https://travis-ci.com/perdata/treap?branch=master)\n[![GoDoc](https://godoc.org/github.com/perdata/treap?status.svg)](https://godoc.org/github.com/perdata/treap)\n[![codecov](https://codecov.io/gh/perdata/treap/branch/master/graph/badge.svg)](https://codecov.io/gh/perdata/treap)\n[![GoReportCard](https://goreportcard.com/badge/github.com/perdata/treap)](https://goreportcard.com/report/github.com/perdata/treap)\n\nPackage treap implements an immutabe sorted set datastructure using a combination tree/heap or [treap](https://en.wikipedia.org/wiki/Treap).\n\nThe algorithms are mostly based on [Fast Set Operations Using Treaps](https://www.cs.cmu.edu/~scandal/papers/treaps-spaa98.pdf)\n\nAlthough the package is oriented towards ordered sets, it is simple to convert it to work as a persistent map.  There is a working [example](https://godoc.org/github.com/perdata/treap#example-package--OrderedMap) showing how to do this.\n\n\n##  Benchmark stats\n\nThe most interesting benchmark is the performance of insert where a\nsingle random key is inserted into a 5k sized map.  As the example\nshows, the treap structure does well here as opposed to a regular\nimmutable map (using full copying).  This benchmark does not\ntake into account the fact that the regular maps are not sorted unlike\ntreaps. \n\nThe intersection benchmark compares the case where two 10k sets with\n5k in common being interesected. The regular map is about\n30% faster but this is still respectable showing for treaps. \n\n\n```sh\n$ go test --bench=. -benchmem\ngoos: darwin\ngoarch: amd64\npkg: github.com/perdata/treap\nBenchmarkInsert-4                   \t 1000000\t      2347 ns/op\t    1719 B/op\t      36 allocs/op\nBenchmarkInsertRegularMap-4         \t    2000\t    890745 ns/op\t  336311 B/op\t       8 allocs/op\nBenchmarkIntersection-4             \t     500\t   3125772 ns/op\t 1719838 B/op\t   35836 allocs/op\nBenchmarkIntersectionRegularMap-4   \t     500\t   2436519 ns/op\t  718142 B/op\t     123 allocs/op\nBenchmarkUnion-4                    \t    1000\t   1451047 ns/op\t  939846 B/op\t   19580 allocs/op\nBenchmarkDiff-4                     \t     500\t   3280823 ns/op\t 1742080 B/op\t   36298 allocs/op\nPASS\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperdata%2Ftreap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperdata%2Ftreap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperdata%2Ftreap/lists"}