{"id":13712536,"url":"https://github.com/mcxxmc/structures-in-go","last_synced_at":"2025-08-21T03:31:55.444Z","repository":{"id":230676985,"uuid":"432155783","full_name":"mcxxmc/structures-in-go","owner":"mcxxmc","description":"Implementation of some data structures in golang. e.g. Binary search tree.","archived":false,"fork":false,"pushed_at":"2022-01-04T06:01:58.000Z","size":75,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T03:12:31.940Z","etag":null,"topics":["data-structures","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcxxmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-11-26T11:32:32.000Z","updated_at":"2023-02-06T23:42:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"d350d4b8-2647-451f-971a-6173b0f52651","html_url":"https://github.com/mcxxmc/structures-in-go","commit_stats":null,"previous_names":["mcxxmc/structures-in-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mcxxmc/structures-in-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fstructures-in-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fstructures-in-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fstructures-in-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fstructures-in-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcxxmc","download_url":"https://codeload.github.com/mcxxmc/structures-in-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fstructures-in-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271420473,"owners_count":24756569,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","go","golang"],"created_at":"2024-08-02T23:01:19.538Z","updated_at":"2025-08-21T03:31:55.170Z","avatar_url":"https://github.com/mcxxmc.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# structures-in-go\n Implementation of some data structures in golang. e.g. Binary search tree.\n\n Most of the implemented structures support interface{} as the input type,\nwhich means you can use them to store any customized input. However, \nthe output type of the structures is also interface{} or []interface{}, \n which means you need to manually perform type assertion: e.g.,\n    \n    b = a.(int)\n\nCurrently supported and tested structures include:\n1. stack\n2. queue\n3. linked list\n4. binary heap\n5. binary search tree\n6. red black tree\n7. fibonacci heap (in process)\n\n\nPlease always use the safe constructor (e.g., `NewStack()`) to initialize any structure.\n\nSome attributes in the structures are protected from outside access for safety reasons; \nplease call corresponding methods when necessary.\n\nAll trees use the successor for replacement in deletion.\n\n## The \"compare\" method \nMany structures require a \"compare\" function as the input for the safe constructor. \nA \"compare\" function is in the form of `func(a, b interface) int`.\n1. \"compare\" is the class method for comparing different values in the structure (e.g., node values);\n2. it should return 1 if a \u003e b , 0 if a == b, -1 if a \u003c b;\n3. the first parameter, `a`, should always be an element from the struct other than user input. \nfor example, in a tree, `a` should be the same type as the value of the tree node.\n4. the second parameter, `b`, may have variant types. A tricky compare method can \nrelax the conditions for Search and Delete; please see examples for details. \n\nOne simple example:\n\n    func compareInt (a, b interface{}) int {\n        if a.(int) \u003e b.(int) {\n            return 1\n        } else if a.(int) == b.(int) {\n            return 0\n        }\n        return -1\n    }\n\nA tricky example:\n\n    func trickyCompare (a, b interface{}) int {\n        a1 := a.(someDataStructure).Val\n        var b1 int\n        switch b.(type) {\n        case SomeDataStructure:\n            b1 = b.(someDataStructure).Val\n        case int:\n            b1 = b.(int)\n        }\n        if a1 \u003e b1 {return 1} else if a1 == b1 {return 0} else {return -1)\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcxxmc%2Fstructures-in-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcxxmc%2Fstructures-in-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcxxmc%2Fstructures-in-go/lists"}