chunks

package
v0.0.0-...-e80cf58 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(size, chunkSize int64) int64

Count returns the number of Chunks of size chunkSize needed to cover the range [0, size).

func Of

func Of(size, chunkSize int64) iter.Seq[Chunk]

Of returns a sequence of contiguous Chunks of size chunkSize that cover the range [0, size), in order.

Types

type Chunk

type Chunk struct {
	Start, End int64
}

func New

func New(start, end int64) Chunk

func Parse

func Parse(s string) (Chunk, error)

Parse parses a string in the form "start-end" and returns the Chunk.

func ParseRange

func ParseRange(s string) (unit string, _ Chunk, _ error)

ParseRange parses a string in the form "unit=range" where unit is a string and range is a string in the form "start-end". It returns the unit and the range as a Chunk.

func (Chunk) Size

func (c Chunk) Size() int64

Size returns end minus start plus one.

func (Chunk) String

func (c Chunk) String() string

String returns the string representation of the Chunk in the form "{start}-{end}".

Jump to

Keyboard shortcuts

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