Documentation ¶
Index ¶
- Constants
- func DumpByteSlice(b []byte, bytesPerRow int, showASCII, showPosHex, showPosDec bool, ...) (out string)
- func DumpByteSlicesWithDiffs(a, b []byte, bytesPerRow int, showASCII, showPosHex, showPosDec bool) (different bool, out string)
- func Uniqify[T comparable](s []T) []T
- type Bitmap
- func (bm *Bitmap) Clear(location int) error
- func (bm *Bitmap) FirstFree(start int) int
- func (bm *Bitmap) FirstSet() int
- func (bm *Bitmap) FreeList() []Contiguous
- func (bm *Bitmap) FromBytes(b []byte)
- func (bm *Bitmap) IsSet(location int) (bool, error)
- func (bm *Bitmap) Set(location int) error
- func (bm *Bitmap) ToBytes() []byte
- type Contiguous
Constants ¶
const (
// AppNameVersion name and URL to app
AppNameVersion = "https://github.com/diskfs/go-diskfs"
)
Variables ¶
This section is empty.
Functions ¶
func DumpByteSlice ¶ added in v1.4.2
func DumpByteSlice(b []byte, bytesPerRow int, showASCII, showPosHex, showPosDec bool, showOnlyBytes []int) (out string)
DumpByteSlice dump a byte slice in hex and optionally ASCII format. Optionally but position at the beginning of each row, like xxd. Optionally convert to ASCII at end of each row, like xxd. Can show positions at beginning of each row in hex, decimal or both. Can filter out all rows except those containing given positions in showOnlyBytes. If showOnlyBytes is nil, all rows are shown. If showOnlyBytes is not nil, even an empty slice, will only show those rows that contain the given positions.
func DumpByteSlicesWithDiffs ¶ added in v1.4.2
func DumpByteSlicesWithDiffs(a, b []byte, bytesPerRow int, showASCII, showPosHex, showPosDec bool) (different bool, out string)
DumpByteSlicesWithDiffs show two byte slices in hex and ASCII format, with differences highlighted.
func Uniqify ¶ added in v1.4.1
func Uniqify[T comparable](s []T) []T
Types ¶
type Bitmap ¶ added in v1.4.1
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap is a structure holding a bitmap
func BitmapFromBytes ¶ added in v1.4.1
BitmapFromBytes create a bitmap struct from bytes
func NewBitmap ¶ added in v1.4.1
NewBitmap creates a new bitmap of size bytes; it is not in bits to force the caller to have a complete set
func (*Bitmap) FirstFree ¶ added in v1.4.1
FirstFree returns the first free bit in the bitmap Begins at start, so if you want to find the first free bit, pass start=1. Returns -1 if none found.
func (*Bitmap) FreeList ¶ added in v1.4.1
func (bm *Bitmap) FreeList() []Contiguous
FreeList returns a slicelist of contiguous free locations by location. It is sorted by location. If you want to sort it by size, uses sort.Slice for example, if the bitmap is 10010010 00100000 10000010, it will return
1: 2, // 2 free bits at position 1 4: 2, // 2 free bits at position 4 8: 3, // 3 free bits at position 8 11: 5 // 5 free bits at position 11 17: 5 // 5 free bits at position 17 23: 1, // 1 free bit at position 23
if you want it in reverse order, just reverse the slice.
func (*Bitmap) FromBytes ¶ added in v1.4.1
FromBytes overwrite the existing map with the contents of the bytes. It is the equivalent of BitmapFromBytes, but uses an existing Bitmap.
type Contiguous ¶ added in v1.4.1
Contiguous a position and count of contiguous bits, either free or set