{"id":15626999,"url":"https://github.com/shirshendubhowmick/golang-data-structures","last_synced_at":"2025-03-29T17:26:02.081Z","repository":{"id":47331579,"uuid":"296117505","full_name":"shirshendubhowmick/golang-data-structures","owner":"shirshendubhowmick","description":"Popular data strctures \u0026 algorithms in Go lang","archived":false,"fork":false,"pushed_at":"2025-03-03T21:44:50.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-03T22:28:34.628Z","etag":null,"topics":["data-structures","datastructures","go","golang","linked-list","tree"],"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/shirshendubhowmick.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-09-16T18:37:08.000Z","updated_at":"2025-03-03T21:44:54.000Z","dependencies_parsed_at":"2022-07-20T17:18:29.393Z","dependency_job_id":null,"html_url":"https://github.com/shirshendubhowmick/golang-data-structures","commit_stats":null,"previous_names":["shirshendubhowmick/golang-algorithms"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirshendubhowmick%2Fgolang-data-structures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirshendubhowmick%2Fgolang-data-structures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirshendubhowmick%2Fgolang-data-structures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shirshendubhowmick%2Fgolang-data-structures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shirshendubhowmick","download_url":"https://codeload.github.com/shirshendubhowmick/golang-data-structures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246217771,"owners_count":20742266,"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":["data-structures","datastructures","go","golang","linked-list","tree"],"created_at":"2024-10-03T10:14:54.163Z","updated_at":"2025-03-29T17:26:02.058Z","avatar_url":"https://github.com/shirshendubhowmick.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang Data Structures\n\nPackages of commonly used data structures and algorithms. Supports go module.\n\n[![Tests](https://github.com/shirshendubhowmick/golang-data-structures/actions/workflows/tests.yml/badge.svg)](https://github.com/shirshendubhowmick/golang-data-structures/actions/workflows/tests.yml)\n\n## Note: This is a WIP project, contributions are welcomed.\n\n## Table of contents\n* [Quickstart](#Quickstart)\n* [Installation](#Installation)\n* [Directory structure](#Directory-structure)\n* [Package contents](#Package-contents)\n\n## Quickstart\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/shirshendubhowmick/golang-data-structures/pkg/linkedlist/sll\"\n)\n\nfunc main() {\n\tlist := sll.InitList(4)\n\n\tlist.Append(5)\n\tnodeRef0 := list.Append(6)\n\tlist.Append(7)\n\tlist.Append(8)\n\n\tlist.Prepend(3)\n\tnodeRef1 := list.Prepend(2)\n\tlist.Prepend(1)\n\tlist.Prepend(0)\n\n\tlist.Print()\n\n\tlist.RemoveByIndex(4)\n\n\tlist.Print()\n\n\tfmt.Println(list.Get(4))\n\n\tfmt.Println(list.IndexOf(8))\n\n\tlist.ReplaceByIndex(7, 99)\n\tlist.Print()\n\n\tfmt.Println(list.ToSlice())\n\tfmt.Println(list.Length())\n\n\tfmt.Println(list.InsertAt(8, 200))\n\tlist.Print()\n\n\t_, nodeRef2, _ := list.ReplaceByNode(nodeRef1, 999)\n\tlist.Print()\n\n\tlist.RemoveByNode(nodeRef2)\n\tlist.Print()\n\n\tlist.InsertAfter(nodeRef0, 500)\n\tlist.Print()\n\n\tlist.InsertBefore(nodeRef0, 600)\n\tlist.Print()\n}\n```\n\n## Installation\nThis was developved in go `v1.15` and not tested in any other lower version as of now.\n\nInside your main module run\n\n```bash\ngo get github.com/shirshendubhowmick/golang-data-structures/pkg\n```\n\n\n## Directory structure\n\nThis repo uses go modules, `pkg` is the module directory and it contains all the packages.\nPackages are distributed based on their data structure.\nFor example\n\n`pkg/linkedlist` contains packages `sll`, `dll` etc\n\n`pkg/tree` contains packages `btree`, `avltree` etc\n\nAny packages inside an `internal` directory are meant for internal use, do not consume them directly.\n\n\u003cbr\u003e\nExamples are located in `examples` directory, they are also distributed in the same way as packages.\nFor example\n\n`examples/linkedList` directory contains all examples related to linked lists\n\n## Package contents\n\n* [**Linked lists**](#Linked-lists)\n  * [Singly linked list](#Singly-linked-list)\n  * [Doubly linked list](#Doubly-linked-list)\n  * Circular linked list\n\n* **Stack**\n  * Array stack\n  * Linked list stack\n\n* **Queue**\n  * Normal queue\n  * Priority queue\n  * Deque\n  * Circular queue\n\n* **Tree**\n\t* Binary search tree\n\t* AVL tree\n\t* B Tree\n\nMany more coming soon...\n\n\n## Linked lists\nAll linked lists uses type `interface {}` for the payload, as the list allows any type of data to be stored and also internally it doesn't perform any operations on the payload.\n\nIt is recommended that consumer of linked lists define a proper type to the payload, to have compile time type safety. As it is expected that consumers are going to perform operations on the payload.\n\n* ### Singly linked list\n  Package location:\n `github.com/shirshendubhowmick/golang-data-structures/pkg/linkedlist/sll`\n\n  [See examples](examples/linkedList/singlyLinkedList/)\n\t\n\t[Package README](pkg/linkedlist/sll)\n\n\n* ### Doubly linked list\n  Package location:\n `github.com/shirshendubhowmick/golang-data-structures/pkg/linkedlist/dll`\n\n  [See examples](examples/linkedList/doublyLinkedList/)\n\t\n\t[Package README](pkg/linkedlist/sll)\n  \n  \n\n#### Note: Detailed documentation WIP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshirshendubhowmick%2Fgolang-data-structures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshirshendubhowmick%2Fgolang-data-structures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshirshendubhowmick%2Fgolang-data-structures/lists"}