enumbitmap

package
v1.101.8 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package enumbitmap provides functions to encode slices of enumeration strings into integer bitmap values and vice versa.

Each bit correspond to a unique enumeration value. It supports maximum 32 bit (33 distinct values including NONE).

Example with 8 bits:

00000000 =   0 dec = NONE
00000001 =   1 dec = FIRST
00000010 =   2 dec = SECOND
00000100 =   4 dec = THIRD
00001000 =   8 dec = FOURTH
00010000 =  16 dec = FIFTH
00100000 =  32 dec = SIXTH
01000000 =  64 dec = SEVENTH
10000000 = 128 dec = EIGHTH
00001001 = 1 + 8 = 9 dec = FIRST + FOURTH

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitMapToStrings

func BitMapToStrings(enum map[int]string, v int) ([]string, error)

BitMapToStrings converts a int bitmap value into a string slice.

Example
Output:

[third fifth seventh]

func StringsToBitMap

func StringsToBitMap(enum map[string]int, s []string) (int, error)

StringsToBitMap converts a string slice into a int bitmap value.

Example
Output:

42

Types

This section is empty.

Jump to

Keyboard shortcuts

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