{"id":15007480,"url":"https://github.com/kazu/elist_head","last_synced_at":"2026-02-06T12:16:36.348Z","repository":{"id":57640797,"uuid":"434056684","full_name":"kazu/elist_head","owner":"kazu","description":"elist_head is embedded list head of Linked List for store slice","archived":false,"fork":false,"pushed_at":"2021-12-23T20:56:50.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T06:15:01.771Z","etag":null,"topics":["concurrent","go","golang","linked-list","linux-kernel","lock-free"],"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/kazu.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":"2021-12-02T02:32:35.000Z","updated_at":"2024-02-11T16:31:42.000Z","dependencies_parsed_at":"2022-09-05T02:40:36.370Z","dependency_job_id":null,"html_url":"https://github.com/kazu/elist_head","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/kazu/elist_head","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazu%2Felist_head","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazu%2Felist_head/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazu%2Felist_head/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazu%2Felist_head/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kazu","download_url":"https://codeload.github.com/kazu/elist_head/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kazu%2Felist_head/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266151524,"owners_count":23884436,"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":["concurrent","go","golang","linked-list","linux-kernel","lock-free"],"created_at":"2024-09-24T19:10:16.068Z","updated_at":"2026-02-06T12:16:36.252Z","avatar_url":"https://github.com/kazu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# elist_head \n\nelist_head is fastest embedded doubly linked list like a linux kernel's LIST_HEAD for golang\n\n\n# feature\n\nbasic features is the same with [lista_encabezado].\n- alternatives for container/list. container/list allocate per set new element. but elist_head is embedded to struct. not over allocatation.\n- [lista_encabezado] is prev/next normal pointer. elist_head is relative pointer version. relative pointer should not be used in golang. elist_head element should be used in slices.\n- if [lista_encabezado] 's element store to slice, slice append , element pointer changed . so you must change all efercnce element's prev/next. but elist_head is condition referernce in slice. \n\n\n# require \n\n`golang \u003e 1.17`\n\n\n# basic usaage\n\nsample is in `sample_entry.go`\n\n\n```go\ntype SampleEntry struct {\n\tName string\n\tAge  int\n\tListHead\n}\n\nvar EmptySampleEntry *SampleEntry = nil\n\nconst sampleEntryOffset = unsafe.Offsetof(EmptySampleEntry.ListHead)\n\nfunc SampleEntryFromListHead(head *elist_head.ListHead) *SampleEntry {\n\treturn (*SampleEntry)(ElementOf(unsafe.Pointer(head), sampleEntryOffset))\n}\n\nfunc (s *SampleEntry) Offset() uintptr {\n\treturn sampleEntryOffset\n}\n\nfunc (s *SampleEntry) PtrListHead() *elist_head.ListHead {\n\treturn \u0026(s.ListHead)\n}\n\nfunc (s *SampleEntry) fromListHead(l *elist_head.ListHead) *SampleEntry {\n\treturn SampleEntryFromListHead(l)\n}\n\nfunc (s *SampleEntry) FromListHead(l *elist_head.ListHead) List {\n\treturn s.fromListHead(l)\n}\n\nfunc (s *SampleEntry) Prev() *S*ampleEntry {\n\treturn s.fromListHead(s.ListHead.Prev())\n}\nfunc (s *SampleEntry) Next() *S*ampleEntry {\n\treturn s.fromListHead(s.ListHead.Prev())\n}\n\nfunc (s *SampleEntry) InsertBefore(n *SampleEntry) (err error) {\n\t_, err = s.ListHead.InsertBefore(\u0026n.ListHead)\n\treturn\n}\n\n\nfunc main() {\n\n\n    list := elist_head.NewEmptyList()\n\n    elems := make([]SampleEntry, 10)\n\n\n    elem := \u0026elems[0]\n    elem.Name = \"namae dayo\"\n    elem.age = 10\n\n    elems[1].Name = \"namae dayo\"\n    elems[1].age = 15\n    \n    // add elem last of list\n    list.Tail().InsertBefore(\u0026elem.ListHead)\n    // add elems[1] before elemens[0]\n    elem.InsertBefore(\u0026elems[1])\n\n    // get \n    entry := EmptySampleEntry.FromListHead(list.Head().Next()).(*SampleEntry)\n    name := entry.Name\n\n\n    // get before element using Prev()\n    nEntry := elem.Prev()\n\n}\n```\n\n\n\n\n[lista_encabezado]: https://github.com/kazu/loncha/tree/master/lista_encabezado","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazu%2Felist_head","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkazu%2Felist_head","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazu%2Felist_head/lists"}