Source File
queue.go
Belonging Package
github.com/pion/sctp
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage sctptype queue[ any] struct {buf []head inttail intcount int}const minCap = 16func newQueue[ any]( int) *queue[] {:= minCapfor < {<<= 1}return &queue[]{buf: make([], ),}}func ( *queue[]) () int {return .count}func ( *queue[]) ( ) {.growIfFull().buf[.tail] =.tail = (.tail + 1) % len(.buf).count++}func ( *queue[]) () {:= .buf[.head]var.buf[.head] =.head = (.head + 1) % len(.buf).count--return}func ( *queue[]) () {return .buf[.head]}func ( *queue[]) () {return .buf[(.tail-1+len(.buf))%len(.buf)]}func ( *queue[]) ( int) {return .buf[(.head+)%(len(.buf))]}func ( *queue[]) () {if .count < len(.buf) {return}:= make([], .count<<1)if .tail > .head {copy(, .buf[.head:.tail])} else {:= copy(, .buf[.head:])copy([:], .buf[:.tail])}.head = 0.tail = .count.buf =}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |