bytes

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstIndex

func FirstIndex(tokens [][]byte, target []byte) (uint32, bool)

FirstIndex searches for the first occurrence of a byte in a byte slice.

Parameters:

  • tokens: the byte slice to search in.
  • target: the byte to search for.

Returns:

  • uint32: the index of the first occurrence of the byte in the byte slice, or 0 if not found.
  • bool: true if the byte was found, false otherwise.

Panics:

  • common.ErrMaxSizeExceeded: if the length of the slice is greater than common.MaxSliceSize.

func ForwardSearch

func ForwardSearch(data []byte, from uint32, sep []byte) (uint32, bool)

ForwardSearch searches for the first occurrence of a byte in a byte slice.

Parameters:

  • data: the byte slice to search in.
  • from: the index to start the search from.
  • sep: the byte to search for.

Returns:

  • uint32: the index of the first occurrence of the byte in the byte slice, or 0 if not found.
  • bool: true if the byte was found, false otherwise.

Panics:

  • common.ErrMaxSizeExceeded: if the length of the slice is greater than common.MaxSliceSize.

func LimitLines

func LimitLines(data []byte, limit uint32) ([]byte, error)

LimitLines is a function that limits the lines of the data.

Parameters:

  • data: The data to limit.
  • limit: The limit of the lines.

Returns:

  • []byte: The limited data.
  • error: An error if limiting fails.

Errors:

  • common.ErrMaxSizeExceeded: If the size of the data is greater than common.MaxSliceSize.

func LimitReverseLines

func LimitReverseLines(data []byte, limit uint32) ([]byte, error)

LimitReverseLines is a function that limits the lines of the data in reverse order.

Parameters:

  • data: The data to limit.
  • limit: The limit of the lines.

Returns:

  • []byte: The limited data.
  • error: An error if limiting fails.

Errors:

  • common.ErrMaxSizeExceeded: If the size of the data is greater than common.MaxSliceSize.

func ReverseSearch

func ReverseSearch(data []byte, from uint32, sep []byte) (uint32, bool)

ReverseSearch searches for the last occurrence of a byte in a byte slice.

Parameters:

  • data: the byte slice to search in.
  • from: the index to start the search from.
  • sep: the byte to search for.

Returns:

  • uint32: the index of the last occurrence of the byte in the byte slice, or 0 if not found.
  • bool: true if the byte was found, false otherwise.

Panics:

  • common.ErrMaxSizeExceeded: if the length of the slice is greater than common.MaxSliceSize.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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