{"id":37116128,"url":"https://github.com/thrimbda/dune","last_synced_at":"2026-01-14T13:37:35.443Z","repository":{"id":186685976,"uuid":"69208841","full_name":"Thrimbda/dune","owner":"Thrimbda","description":"Dune of data-structures","archived":false,"fork":false,"pushed_at":"2018-01-29T14:33:38.000Z","size":134,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-05T00:25:36.341Z","etag":null,"topics":["data-structures","dune"],"latest_commit_sha":null,"homepage":"","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/Thrimbda.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,"governance":null}},"created_at":"2016-09-26T03:18:46.000Z","updated_at":"2018-01-16T12:25:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"ac4ee5e0-e9fa-4b3a-b081-5e8fe982d8aa","html_url":"https://github.com/Thrimbda/dune","commit_stats":null,"previous_names":["thrimbda/dune"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Thrimbda/dune","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thrimbda%2Fdune","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thrimbda%2Fdune/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thrimbda%2Fdune/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thrimbda%2Fdune/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thrimbda","download_url":"https://codeload.github.com/Thrimbda/dune/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thrimbda%2Fdune/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28421401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["data-structures","dune"],"created_at":"2026-01-14T13:37:34.722Z","updated_at":"2026-01-14T13:37:35.431Z","avatar_url":"https://github.com/Thrimbda.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DUNE-沙丘\n\n\u003e 聚沙成塔\n\n[![Build Status](https://travis-ci.org/Thrimbda/dune.svg?branch=master)](https://travis-ci.org/Thrimbda/dune)\n[![Coverage Status](https://coveralls.io/repos/github/Thrimbda/dune/badge.svg?branch=master)](https://coveralls.io/github/Thrimbda/dune?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Thrimbda/dune)](https://goreportcard.com/report/github.com/Thrimbda/dune)\n\n一个用 `Golang`实现的基础数据结构集.\n\n\n## 数据结构\n\n基础的元数据均为实现了以下接口的任意数据结构。\n\n```go\ntype Elem interface {\n\tLessComparator(b Elem) bool\n\t//return true if a \u003c b\n}\n```\n\n### 基本数据结构\n\n#### 线性表\n\n线性表接口如下\n\n```go\n//List interface which doesn't support resize yet.\ntype List interface {\n\tInsert(index int, items ...interface{})\n\tAppend(items ...interface{})\n\tRemove(index int) interface{}\n\tLength() int\n\tGet(index int) interface{}\n\tSetValue(index int, value interface{})\n\tContains(value interface{}) bool\n\tIndexOf(value interface{}) int\n\tClear()\n\tIsEmpty() bool\n}\n```\n\n拥有链表与顺序表两种实现方式。\n\n#### 栈\n\n```go\n//Stack interface\ntype Stack interface {\n\tClear()\n\tPush(item interface{})\n\tPop() interface{}\n\tPeek() interface{}\n\tIsEmpty() bool\n}\n```\n\n#### 队列\n\n```go\n//Queue interface.\ntype Queue interface {\n\tClear()\n\tEnqueue(item interface{})\n\tDequeue() interface{}\n\tPeek() interface{}\n\tIsEmpty() bool\n}\n```\n\n### 二叉树\n\n二叉树节点接口\n\n```go\ntype BinNode interface {\n  Element() Elem\n  SetElement(element Elem)\n  Left() BinNode\n  SetLeft(node BinNode)\n  Right() BinNode\n  SetRight(node BinNode)\n  SetParent(node BinNode)\n  Parent() BinNode\n  IsLeaf() bool\n}\n```\n\n#### 二叉搜索树 (BST)\n\n```go\ntype BST interface {\n  Insert(value Elem)\n  Search(key int) BST\n  Delete(key int)\n  Predecessor() BST //寻找前驱节点\n  Successor() BST //寻找后继\n  Minimum() BST\n  Maximum() BST\n  InorderWalk() //中序遍历\n}\n```\n\n二叉搜索树除基本实现以外，还有许多平衡树实现。\n\n目前实现了红黑树。\n\n#### 堆\n\n由于堆为满二叉树，因此使用数组实现，故并未使用上述二叉树结点。\n\n```go\ntype Heap interface {\n  setup(size int)\n  heapSize() int\n  isLeaf(pos int) bool\n  buildHeap()\n  leftChild(pos int) int\n  rightChile(pos int) int\n  parent(pos int) int\n  shiftDown(pos int)\n  insert(val Elem)\n  removeMax() Elem\n  remove(pos int) Elem\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthrimbda%2Fdune","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthrimbda%2Fdune","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthrimbda%2Fdune/lists"}