strings

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: GPL-3.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceCharIndex

func ReplaceCharIndex(old string, indices []int, new ...string) string

Will replace all characters at the given indices with the new strings. Returns a new string.

Indices are all the character indices with which to replace with the new string. Each occurrence will be replaced by the string new[occCount % len(new)]. Where occCount is the current count of the indices that have been replaced.

func ReplaceCharIndexRange

func ReplaceCharIndexRange(old string, indices [][]int, new ...string) string

Similar to ReplaceCharIndex but takes multiple index ranges in the form of [start, end].

The length of new strings must be less than or equal to the length of the indices slice. The length of indices must also be greater than 0. If any of these conditions are not met the old string shall be returned.

func StripWhitespace

func StripWhitespace(str string) string

Given a string, will strip all whitespace from it and return a new string without any whitespace.

Types

type StringHeap

type StringHeap []string

A priority queue which sorts strings lexicographically.

func (StringHeap) Len

func (spq StringHeap) Len() int

The length of the StringHeap.

func (StringHeap) Less

func (spq StringHeap) Less(i, j int) bool

Compares two string elements in the StringHeap.

Uses strings.Compare internally.

func (*StringHeap) Pop

func (spq *StringHeap) Pop() interface{}

Pops the tail of the queue.

func (*StringHeap) Push

func (spq *StringHeap) Push(x interface{})

Pushes the given interface{} to the heap.

Will panic if given interface{} is not a string.

func (StringHeap) Swap

func (spq StringHeap) Swap(i, j int)

Swaps the two elements indicated via the given indices.

Jump to

Keyboard shortcuts

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