intmapper

package
v0.0.0-...-f4b2804 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

intconv defines IntConversor structure which can be used to map integers between two ranges

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntMapper

type IntMapper struct {
	// contains filtered or unexported fields
}

IntConversor is a type that allows to map numbers between two or more ranges

func New

func New() IntMapper

Returns a new initialized conversor

func (*IntMapper) AddMapping

func (ic *IntMapper) AddMapping(from, to, length int)

Adds a new mapping. The behaviour is not defined for multiple overlapping ranges.

func (IntMapper) IsMapped

func (ic IntMapper) IsMapped(n int) bool

IsMapped returns true if the given number is inside a mapped rule

func (IntMapper) Transform

func (ic IntMapper) Transform(n int) int

Transform applies the mappings to the given integer n. If no mappings are found then n is returned

Jump to

Keyboard shortcuts

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