{"id":35106815,"url":"https://github.com/martianoff/go-hpds","last_synced_at":"2026-05-18T20:04:38.955Z","repository":{"id":54732410,"uuid":"304162688","full_name":"martianoff/go-hpds","owner":"martianoff","description":"High performance and easy to use datastructure packages for Golang","archived":false,"fork":false,"pushed_at":"2021-02-02T04:19:56.000Z","size":65,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T22:23:58.549Z","etag":null,"topics":["algorithms","datastructures","disjoint-set","go","golang","linkedlist","maxheap","minheap","packages","priority-queue","queue","stack","trie","union-find"],"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/martianoff.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":"2020-10-14T23:53:02.000Z","updated_at":"2024-07-05T07:53:15.000Z","dependencies_parsed_at":"2022-08-14T01:10:20.639Z","dependency_job_id":null,"html_url":"https://github.com/martianoff/go-hpds","commit_stats":null,"previous_names":["maksimru/go-linkedlist","martianoff/go-hpds","maksimru/go-hpds"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/martianoff/go-hpds","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martianoff%2Fgo-hpds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martianoff%2Fgo-hpds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martianoff%2Fgo-hpds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martianoff%2Fgo-hpds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martianoff","download_url":"https://codeload.github.com/martianoff/go-hpds/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martianoff%2Fgo-hpds/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33189279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"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":["algorithms","datastructures","disjoint-set","go","golang","linkedlist","maxheap","minheap","packages","priority-queue","queue","stack","trie","union-find"],"created_at":"2025-12-27T18:18:46.143Z","updated_at":"2026-05-18T20:04:38.949Z","avatar_url":"https://github.com/martianoff.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/maksimru/go-hpds.svg?style=svg\u0026circle-token=1ff20ea621c63005a3dab9250eb68790c1b5049f)](https://circleci.com/gh/maksimru/go-hpds)\n[![codecov](https://codecov.io/gh/maksimru/go-hpds/branch/master/graph/badge.svg?token=9R19KZFQ09)](https://codecov.io/gh/maksimru/go-hpds/)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/maksimru/go-hpds)](https://pkg.go.dev/github.com/maksimru/go-hpds)\n[![Go Report Card](https://goreportcard.com/badge/github.com/maksimru/go-hpds)](https://goreportcard.com/report/github.com/maksimru/go-hpds)\n\n# High-Performance Datastructures\n\n## Supported Data Structures\n- [SinglyLinkedList](#SinglyLinkedList)\n- [DoublyLinkedList](#DoublyLinkedList)\n- [Queue](#Queue)\n- [Stack](#Stack)\n- [MaxHeap](#MaxHeap)\n- [MinHeap](#MinHeap)\n- [PriorityQueue](#PriorityQueue)\n- [Trie](#Trie)\n- [Union-Find aka Disjoint-Set](#Union-find-Disjoint-set)\n\n---\n## SinglyLinkedList\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/singlylinkedlist\"\n\nvar list = NewSinglyLinkedList()\nlist.Append(1)\nlist.Append(2)\nlist.Append(3)\nvar list2 = NewSinglyLinkedList()\nlist2.Append(5)\nlist2.Append(6)\nlist2.Append(7)\nlist.GetTail().AppendList(list2)\nlist.Print() //returns \"1 -\u003e 2 -\u003e 3 -\u003e 5 -\u003e 6 -\u003e 7\"\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| SinglyLinkedList  | Purge  | O(1)  |  O(1)  | Purges entire list |\n| SinglyLinkedList  | Join  | O(1)  |  O(1) | Joins two linkedlists |\n| SinglyLinkedList  | GetLength  | O(1)  | O(1)  | Gets total length |\n| SinglyLinkedList  | GetTail  | O(1)  | O(1)  | Gets tail node |\n| SinglyLinkedList  | GetHead  | O(1)  | O(1)  | Gets head node |\n| SinglyLinkedList  | Reverse | O(N)  |  O(1)  | Reverses entire list |\n| SinglyLinkedList  | Append | O(1)  | O(1)  | Inserts element to the end |\n| SinglyLinkedList  | Prepend | O(1)  | O(1)  | Inserts element to the begin |\n| SinglyLinkedList  | Unshift | O(1)  | O(1)  | Shift element from the begin of linkedlist |\n| SinglyLinkedList  | Print |  O(N)  | O(N)  | Prints linkedlist |\n| Node (SinglyLinkedList)  | Split |  O(K)  | O(1)  | Splits linkedlist into two |\n| Node (SinglyLinkedList)  | ReverseFrom |  O(K)  | O(1)  | Reverses part of linkedlist |\n| Node (SinglyLinkedList)  | AppendList |  O(1)  | O(1)  | Appends other linkedlist after node |\n| Node (SinglyLinkedList)  | Append |  O(1)  | O(1)  | Appends value after node |\n| Node (SinglyLinkedList)  | GetList |  O(1)  | O(1)  | Returns list from node |\n| Node (SinglyLinkedList)  | GetNext |  O(1)  | O(1)  | Gets next node |\n| Node (SinglyLinkedList)  | GetValue |  O(1)  | O(1)  | Gets value of node |\n\n---\n## DoublyLinkedList\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/doublylinkedlist\"\n\nvar list = NewDoublyLinkedList()\nlist.Append(1)\nn := list.Append(2)\nlist.Append(3)\nn.Remove()\nlist.Print() //returns \"1 \u003c-\u003e 3\"\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| DoublyLinkedList  | Purge  | O(1)  |  O(1)  | Purges entire list |\n| DoublyLinkedList  | Join  | O(1)  |  O(1) | Joins two linkedlists |\n| DoublyLinkedList  | GetLength  | O(1)  | O(1)  | Gets total length |\n| DoublyLinkedList  | GetTail  | O(1)  | O(1)  | Gets tail node |\n| DoublyLinkedList  | GetHead  | O(1)  | O(1)  | Gets head node |\n| DoublyLinkedList  | Reverse | O(N)  |  O(1)  | Reverses entire list |\n| DoublyLinkedList  | Append | O(1)  | O(1)  | Inserts element to the end |\n| DoublyLinkedList  | Prepend | O(1)  | O(1)  | Inserts element to the begin |\n| DoublyLinkedList  | Pop | O(1)  | O(1)  | Pop element from the end of linkedlist |\n| DoublyLinkedList  | Unshift | O(1)  | O(1)  | Shift element from the begin of linkedlist |\n| DoublyLinkedList  | Print |  O(N)  | O(N)  | Prints linkedlist |\n| Node (DoublyLinkedList)  | Split |  O(K)  | O(1)  | Splits linkedlist into two |\n| Node (DoublyLinkedList)  | ReverseFrom |  O(K)  | O(1)  | Reverses part of linkedlist |\n| Node (DoublyLinkedList)  | AppendList |  O(1)  | O(1)  | Appends other linkedlist after node |\n| Node (DoublyLinkedList)  | Append |  O(1)  | O(1)  | Appends value after node |\n| Node (DoublyLinkedList)  | Prepend |  O(1)  | O(1)  | Prepends value before node |\n| Node (DoublyLinkedList)  | Remove |  O(1)  | O(1)  | Removes node |\n| Node (DoublyLinkedList)  | GetList |  O(1)  | O(1)  | Returns list from node |\n| Node (DoublyLinkedList)  | GetNext |  O(1)  | O(1)  | Gets next node |\n| Node (DoublyLinkedList)  | GetPrev |  O(1)  | O(1)  | Gets prev node |\n| Node (DoublyLinkedList)  | GetValue |  O(1)  | O(1)  | Gets value of node |\n\n---\n## Queue\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/queue\"\n\nqueue := NewQueue()\nqueue.Enqueue(1)\nqueue.Enqueue(2)\nqueue.Enqueue(3)\nqueue.Enqueue(4)\nfor !queue.IsEmpty() {\n    value := queue.Dequeue()\n    // process the queue\n}\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| Queue  | Enqueue  | O(1)  |  O(1)  | Adds element to queue |\n| Queue  | Dequeue  | O(1)  |  O(1) | Pops element from top of queue |\n| Queue  | Top  | O(1)  | O(1)  | Returns top of queue (next candidate for dequeue) |\n| Queue  | Bottom  | O(1)  | O(1)  | Returns bottom of queue (last candidate for dequeue) |\n| Queue  | IsEmpty  | O(1)  | O(1)  | Checks queue is empty |\n| Queue  | GetLength | O(1)  |  O(1)  | Gets queue length |\n| Queue  | Purge | O(1)  |  O(1)  | Purges queue |\n\n---\n## Stack\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/stack\"\n\nstack := NewStack()\nstack.Push(1)\nstack.Push(2)\nstack.Push(3)\nstack.Push(4)\nfor !stack.IsEmpty() {\n    value := stack.Pop()\n    // process the stack\n}\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| Stack  | Push  | O(1)  |  O(1)  | Adds element to stack |\n| Stack  | Pop  | O(1)  |  O(1) | Pops element from top of stack |\n| Stack  | Top  | O(1)  | O(1)  | Get top of stack (last added) |\n| Stack  | Bottom  | O(1)  | O(1)  | Returns bottom of stack (first added) |\n| Stack  | IsEmpty  | O(1)  | O(1)  | Checks stack is empty |\n| Stack  | GetLength | O(1)  |  O(1)  | Gets stack length |\n| Stack  | Purge | O(1)  |  O(1)  | Purges stack |\n\n---\n## MaxHeap\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/maxheap\"\n\narrSlice := []int{0,5,1,6,8,3,5,9,2,6}\nheap := NewMaxHeap(arraylist.NewIntArrayList(arrSlice), comparator.NewIntComparator())\nheap.Remove() //returns 9\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| MaxHeap  | Add  | O(log N)  |  O(1)  | Adds element to the heap |\n| MaxHeap  | Remove  | O(log N)  |  O(1) | Removes element from the top of the heap |\n| MaxHeap  | Top  | O(1)  | O(1)  | Get top of heap |\n| MaxHeap  | IsValid  | O(N)  | O(1)  | Checks heap is valid1 |\n| MaxHeap  | IsEmpty  | O(1)  | O(1)  | Checks heap is empty |\n| MaxHeap  | GetLength | O(1)  |  O(1)  | Gets length of the heap |\n| MaxHeap  | Clean | O(1)  |  O(1)  | Removes all elements from the heap |\n| MaxHeap  | NewMaxHeap | O(N)  |  O(1)  | Build heap |\n---\n\n## MinHeap\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/minheap\"\n\narrSlice := []int{0,5,1,6,8,3,5,9,2,6}\nheap := NewMinHeap(arraylist.NewIntArrayList(arrSlice), comparator.NewIntComparator())\nheap.Remove() //returns 0\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| MinHeap  | Add  | O(log N)  |  O(1)  | Adds element to the heap |\n| MinHeap  | Remove  | O(log N)  |  O(1) | Removes element from the top of the heap |\n| MinHeap  | Top  | O(1)  | O(1)  | Get top of heap |\n| MinHeap  | IsValid  | O(N)  | O(1)  | Checks heap is valid1 |\n| MinHeap  | IsEmpty  | O(1)  | O(1)  | Checks heap is empty |\n| MinHeap  | GetLength | O(1)  |  O(1)  | Gets length of the heap |\n| MinHeap  | Clean | O(1)  |  O(1)  | Removes all elements from the heap |\n| MinHeap  | NewMinHeap | O(N)  |  O(1)  | Build heap |\n---\n\n## PriorityQueue\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/priorityqueue\"\n\narr := []IntPrioritizedValue{NewIntPrioritizedValue(21,5),NewIntPrioritizedValue(2,7),NewIntPrioritizedValue(432,1)}\npq := NewPriorityQueue(NewIntPrioritizedValueList(arr), NewIntPriorityComparator())\nfor !pq.IsEmpty() {\n    value := pq.Dequeue() //returns instance of IntPrioritizedValue value = 2, priority = 7\n}\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| PriorityQueue  | Enqueue  | O(log N)  |  O(1)  | Adds element to the priority queue |\n| PriorityQueue  | Dequeue  | O(log N)  |  O(1) | Removes element from the top of the priority queue |\n| PriorityQueue  | Top  | O(1)  | O(1)  | Get top of priority queue |\n| PriorityQueue  | IsEmpty  | O(1)  | O(1)  | Checks priority queue is empty |\n| PriorityQueue  | GetLength | O(1)  |  O(1)  | Gets length of the priority queue |\n| PriorityQueue  | Clean | O(1)  |  O(1)  | Removes all elements from the priority queue |\n| PriorityQueue  | NewPriorityQueue | O(N)  |  O(1)  | Build priority queue |\n---\n\n## Trie\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/trie\"\n\nvar trie = NewTrie()\ntrie.Add(\"word\", 1)\ntrie.Add(\"work\", 2)\ntrie.Add(\"wor\", 3)\ntrie.Add(\"war\", 4)\ntrie.Add(\"won\", 5)\nv, s := trie.SearchPattern(\"w?r\") //s will return 3 and 4\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| -  | NewTrie  | O(1)  | O(1)  | Builds empty trie |\n| Trie  | GetRoot  | O(1)  |  O(1)  | Returns root trie node |\n| Trie  | Add  | O(M)  |  O(M) | Adds word with custom value to the trie |\n| Trie  | Search  | O(M)  | O(1)  | Searches word in trie using exact match |\n| Trie  | SearchPrefix  | O(M+N*L)  | O(1)  | Searches words in trie using prefix |\n| Trie  | SearchPattern  | O(M*A^X)  | O(1)  | Searches keyword in Trie using pattern match, \"?\" will match any single char |\n| -  | NewNode | O(1)  |  O(1)  | Creates node |\n| Node (Trie)  | GetChar | O(1)  |  O(1)  | Get character in specific node |\n| Node (Trie)  | GetValue | O(1)  |  O(1)  | Get value in specific node |\n| Node (Trie)  | HasTerminator | O(1)  |  O(1)  | Checks if node is the end of word |\n| Node (Trie)  | HasChildNodes | O(1)  |  O(1)  | Checks if node has sub nodes |\n---\n\n## Union-Find (Disjoint-Set)\n\n### Usage\n\n```\nimport \"github.com/maksimru/go-hpds\"\nimport \"github.com/maksimru/go-hpds/unionfind\"\n\nunion := NewUnionFind()\nunion.Union(1,2)\nunion.Union(2,3)\nunion.Union(4,3)\nnode := union.FindInSet(4)  //returns Node with value 1 and rank 4, meaning that all four nodes are in union\n```\n\n### Methods\n\n|  Object  | Operation | Time Complexity  | Space Complexity   | Comment |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| -  | NewUnionFind  | O(1)  | O(1)  | Builds empty union-find |\n| UnionFind  | FindInSet  | O(M)  |  O(1)  | Returns parent node of the union searching by value of its member |\n| UnionFind  | Union  | O(M)  |  O(M) | Joins two unions using any values belonging to them |\n| UnionFind  | Has | O(1)  |  O(1)  | Checks if specific union exists |\n| -  | NewNode | O(1)  |  O(1)  | Creates node |\n| Node (UnionFind)  | GetRank | O(1)  |  O(1)  | Get rank in specific node |\n| Node (UnionFind)  | GetValue | O(1)  |  O(1)  | Get value of specific node |\n---\n## Testing\n\nTo run all tests in this module:\n\n```\ngo test ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartianoff%2Fgo-hpds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartianoff%2Fgo-hpds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartianoff%2Fgo-hpds/lists"}