Source File
fixedbig.go
Belonging Package
github.com/pion/transport/v2/replaydetector
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage replaydetectorimport ()// fixedBigInt is the fix-sized multi-word integer.type fixedBigInt struct {bits []uint64n uintmsbMask uint64}// newFixedBigInt creates a new fix-sized multi-word int.func newFixedBigInt( uint) *fixedBigInt {:= ( + 63) / 64if == 0 {= 1}return &fixedBigInt{bits: make([]uint64, ),n: ,msbMask: (1 << (64 - %64)) - 1,}}// Lsh is the left shift operation.func ( *fixedBigInt) ( uint) {if == 0 {return}:= int( / 64):= % 64for := len(.bits) - 1; >= 0; -- {var uint64if - >= 0 {= .bits[-] <<if --1 >= 0 {|= .bits[--1] >> (64 - )}}.bits[] = (.bits[] << ) |}.bits[len(.bits)-1] &= .msbMask}// Bit returns i-th bit of the fixedBigInt.func ( *fixedBigInt) ( uint) uint {if >= .n {return 0}:= / 64:= % 64if .bits[]&(1<<) != 0 {return 1}return 0}// SetBit sets i-th bit to 1.func ( *fixedBigInt) ( uint) {if >= .n {return}:= / 64:= % 64.bits[] |= 1 <<}// String returns string representation of fixedBigInt.func ( *fixedBigInt) () string {var stringfor := len(.bits) - 1; >= 0; -- {+= fmt.Sprintf("%016X", .bits[])}return}
![]() |
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. |