bitword

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package bitword provides string operations functions

Example
bw4 := BitWord[4]

fmt.Println(bw4.FromStr("abc"))
fmt.Println(bw4.ToStr([]byte{6, 1, 6, 2, 6, 3}))
fmt.Println(bw4.Get("abc", 1))
fmt.Println(bw4.FirstDiff("abc", "abd", 0, -1))
Output:
[6 1 6 2 6 3]
abc
1
5

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// BitWord pre-defines n-bit words operations for 1, 2, 4, 8
	BitWord = map[int]Interface{
		1: newBW(1),
		2: newBW(2),
		4: newBW(4),
		8: newBW(8),
	}
)

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// FromStr split a string into a slice of `n`-bit words in byte.
	//
	// Since 0.1.4
	FromStr(string) []byte
	// FromStrs converts a `[]string` to a n-bit word `[][]byte`.
	//
	// Since 0.1.4
	FromStrs([]string) [][]byte
	// ToStr is the reverse of FromStr.
	//
	// Since 0.1.4
	ToStr([]byte) string
	// ToStrs converts a `[][]byte` back to a `[]string`.
	//
	// Since 0.1.4
	ToStrs([][]byte) []string
	// Get returns i-th n-bit word from a string.
	//
	// Since 0.1.4
	Get(string, int) byte
	// FirstDiff returns the index of the first different n-bit word,
	// from "start" upto "end".
	//
	// Since 0.1.4
	FirstDiff(a, b string, start, end int) int
}

Interface defines operations for n-bit word.

Since 0.1.4

Jump to

Keyboard shortcuts

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