sized_queue

package
v0.0.0-...-d996d1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Copyright 2023 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SizedQueue

type SizedQueue[T any] struct {
	// contains filtered or unexported fields
}

SizedQueue the queue uses the standard `List`. The main difference between `List` is that is capped size, and drops the oldest item when pushing more than its allowed capacity.

func New

func New[T any](capacity int) SizedQueue[T]

New create a new queue with capacity

func (*SizedQueue[T]) Clear

func (s *SizedQueue[T]) Clear()

Clear reset the queue

func (*SizedQueue[T]) Data

func (s *SizedQueue[T]) Data() []T

Data Get the whole data

func (*SizedQueue[T]) Pop

func (s *SizedQueue[T]) Pop() (T, error)

Pop the oldest item.

func (*SizedQueue[T]) Push

func (s *SizedQueue[T]) Push(data T)

Push the new item to the queue. If the size hits the capacity, It will drop the oldest item.

func (*SizedQueue[T]) Size

func (s *SizedQueue[T]) Size() int

Size get the size

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL