{"id":20031184,"url":"https://github.com/gohouse/datastructure","last_synced_at":"2025-05-05T04:31:25.968Z","repository":{"id":112508556,"uuid":"180087553","full_name":"gohouse/dataStructure","owner":"gohouse","description":"the data structure implementation in golang(数据结构的go语言实现, 队列:queue; 散列表:hashtable; 二叉平衡树:avl-tree......)","archived":false,"fork":false,"pushed_at":"2019-09-29T12:25:42.000Z","size":509,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T16:55:14.495Z","etag":null,"topics":["avl-tree","data-structures","go","hashtable","queue"],"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/gohouse.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-08T06:49:57.000Z","updated_at":"2022-03-23T13:35:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"09d51e8c-e13d-4b5b-980d-14a4df7f4133","html_url":"https://github.com/gohouse/dataStructure","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/gohouse%2FdataStructure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gohouse%2FdataStructure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gohouse%2FdataStructure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gohouse%2FdataStructure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gohouse","download_url":"https://codeload.github.com/gohouse/dataStructure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252439631,"owners_count":21748046,"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":["avl-tree","data-structures","go","hashtable","queue"],"created_at":"2024-11-13T09:31:29.402Z","updated_at":"2025-05-05T04:31:25.962Z","avatar_url":"https://github.com/gohouse.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dataStructure\nthe data structure implementation in golang (数据结构的go语言实现, 队列:queue; 散列表:hashtable; 二叉平衡树:avl-tree......)\n\n\n## dataStructure index  \n* [linkedList](#linkedList)  \n* [queue](#queue)  \n* [hashTable](#hashTable)  \n* [tree](#tree)  \n    * [AVL tree](#AVL-tree)  \n    * [binarySearchTree](#binarySearchTree)\n* [stack](#stack)\n* [binaryHeap](#binaryHeap)\n\n## linkedList\n```go\npackage linkedList\n\ntype Node struct {\n\tdata interface{}\n\tnext *Node\n}\n\ntype LinkedList struct {\n\thead *Node\n\tsize int\n}\n\ntype ILinkedList interface {\n\tAddToFirst(data interface{})\n\tAddToLast(data interface{})\n\tShow() (res []interface{})\n\tGet(index int) *Node\n\tGetPrev(index int) *Node\n\tAdd(index int, data interface{}) bool\n\tDelete(index int) bool\n\tReverse() *LinkedList\n\tValueOf(data interface{}) (index int)\n}\n```\n\n## queue\n```go\npackage queue\n\ntype Node struct {\n\tData interface{}\n\tNext *Node\n}\n\ntype Queue struct {\n\thead *Node\n\ttail *Node\n\tsize int\n}\n\ntype IQueue interface {\n\t// 入队列\n\tEnQueue(data *Node) *Queue\n\t// 出队列\n\tDeQueue() *Node\n\t// 构造入队列数据节点\n\tData(data interface{}) *Node\n\t// 获取队列第一个元素,不出队列\n\tPeek() *Node\n\t// 队列是否为空\n\tIsEmpty() bool\n\t// 队列数据数量\n\tSize() int\n\t// 打印队列\n\tShow()\n}\n```\n\n## hashTable\n```go\npackage hashTable\n\ntype Options struct {\n\t// hashtable容量，设置默认桶容量\n\tCapacity uint\n\t// 负载因子 0\u003c= x \u003c=1\n\tLoadFactor float64\n\t// 是否记录扩容log\n\tDebug bool\n}\n\ntype Entry struct {\n\tkey   interface{}\n\tvalue interface{}\n\tnext  *Entry\n}\n\ntype IHashTable interface {\n\t// 添加\n\tPut(key interface{}, value interface{}) error\n\t// 获取key对应的值\n\tGet(key interface{}) interface{}\n\t// 删除\n\tRemove(key interface{}) error\n\t// 当前hashtable的数据量\n\tSize() int\n\t// 是否为空\n\tIsEmpty() bool\n\t// 打印每一个hash槽内的内容\n\tShow()\n}\n```\n\n## tree\n### AVL tree\n```go\npackage avl\n\ntype AvlNode struct {\n\tdata   int\n\tleft   *AvlNode\n\tright  *AvlNode\n}\n\ntype AVLTree struct {\n\troot *AvlNode\n\tsize int\n}\n\ntype IAVLTree interface {\n\t// 添加节点\n\tAdd(data int) *AVLTree\n\t// 树宽\n\tWidth() int\n\t// 树的最大深度\n\tDepth()\n\t// 树的节点数\n\tSize() int\n\t// 横向按层打印树\n\tShow()\n}\n```\n\n### binarySearchTree\n```go\npackage binarySearchTree\n\n//const btdemo = `二叉树示例\n//\t10\n//8\t\t21\n//\t11\t\t30\n//\t\t28\t\t50\n//\t\t\t29\n//`\ntype IBinarySearchTree interface {\n\t// 插入\n\tInsert(i int) bool\n\t// 查找\n\tSearch(i int) *BinarySearchTree\n\t// 最大\n\tMaxNode() *BinarySearchTree\n\t// 最小\n\tMinNode() *BinarySearchTree\n\t// 前序遍历\n\tPreOrder() []int\n\t// 中序遍历\n\tInOrder() []int\n\t// 后续遍历\n\tPostOrder() []int\n\t// 删除\n\tDelete(i int) bool\n\t// 最大深度\n\tDepth() int\n\t// 最小深度\n\tDepthMin() int\n\t// 宽度\n}\n\ntype BinarySearchTree struct {\n\tData        int\n\tLeft, Right *BinarySearchTree\n}\n```\n\n## stack\n```go\npackage stack\n\ntype IStack interface {\n\tPush(data interface{}) bool\n\tPop() interface{}\n\tLength() int\n\tShow()\n}\n\ntype Node struct {\n\tdata interface{}\n\tnext *Node\n}\n```\n\n## binaryHeap\n```go\npackage binaryHeap\n\ntype IBinaryHeap interface {\n\tAdd(data int)\n\tAddSlice(data []int)\n\tLength() int\n\tBuildMax(dataLen int)\n\tBuildMin(dataLen int)\n\tSortAsc()\n\tSortDesc()\n\tShow()\n}\n\ntype BinaryHeap struct {\n\tdata []int\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgohouse%2Fdatastructure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgohouse%2Fdatastructure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgohouse%2Fdatastructure/lists"}