rope

package
v0.0.0-...-249e25c Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package byte allows efficiently manipulating fragmented slices

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rope

type Rope[T any] [][]T

Rope data structure for byte slices

func New

func New[T any](v ...[]T) Rope[T]

New creates a new Rope structure

func (Rope[T]) Copy

func (r Rope[T]) Copy(src ...[]T) (n int)

Copy copies bytes from the src slices to r returning the number of bytes copied

Example
package main

import (
	"github.com/MemeLabs/strims/pkg/rope"
)

func main() {
	src := rope.New([]byte("first chunk"), []byte("second chunk"))
	dst := rope.New(make([]byte, src.Len()/2))
	dst.Copy(src...)
}

func (Rope[T]) Len

func (r Rope[T]) Len() (n int)

Len returns the length of the Rope=

func (Rope[T]) Slice

func (r Rope[T]) Slice(low, high int) (next Rope[T])

Slice returns r modified to include only bytes in the range [low, high)

Example
package main

import (
	"github.com/MemeLabs/strims/pkg/rope"
)

func main() {
	rope.New([]byte("first chunk"), []byte("second chunk")).Slice(5, 10)
}

Jump to

Keyboard shortcuts

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