diff options
| author | 2025-03-12 20:33:35 +0000 | |
|---|---|---|
| committer | 2025-03-12 20:33:35 +0000 | |
| commit | f30bb549aae20281e169d0e7eaf7d70730955f02 (patch) | |
| tree | bfef2396b10ca2af4a96bcbc097f05a191be6bbb /vendor/codeberg.org/gruf/go-structr/list.go | |
| parent | [docs] Update swagger docs command (#3897) (diff) | |
| download | gotosocial-f30bb549aae20281e169d0e7eaf7d70730955f02.tar.xz | |
update go-structr to v0.9.0 with new Timeline{} cache type (#3903)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-structr/list.go')
| -rw-r--r-- | vendor/codeberg.org/gruf/go-structr/list.go | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/list.go b/vendor/codeberg.org/gruf/go-structr/list.go index bf380aa26..7657472c7 100644 --- a/vendor/codeberg.org/gruf/go-structr/list.go +++ b/vendor/codeberg.org/gruf/go-structr/list.go @@ -43,7 +43,7 @@ func free_list(list *list) { if list.head != nil || list.tail != nil || list.len != 0 { - should_not_reach() + should_not_reach(false) return } list_pool.Put(list) @@ -107,6 +107,32 @@ func (l *list) move_back(elem *list_elem) { l.push_back(elem) } +// insert will insert given element at given location in list. +func (l *list) insert(elem *list_elem, at *list_elem) { + if elem == at { + return + } + + // Set new 'next'. + oldNext := at.next + at.next = elem + + // Link to 'at'. + elem.prev = at + + if oldNext == nil { + // Set new tail + l.tail = elem + } else { + // Link to 'prev'. + oldNext.prev = elem + elem.next = oldNext + } + + // Incr count + l.len++ +} + // remove will remove given elem from list. func (l *list) remove(elem *list_elem) { // Get linked elems. @@ -149,3 +175,11 @@ func (l *list) remove(elem *list_elem) { // Decr count l.len-- } + +// func (l *list) range_up(yield func(*list_elem) bool) { + +// } + +// func (l *list) range_down(yield func(*list_elem) bool) { + +// } |
