{"modulePath":"github.com/ejfkdev/udf","version":"v0.7.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package bitmap\n\n## Types\n\n```go\ntype Bitmap struct {\n\t// contains filtered or unexported fields\n}\n```\nBitmap is a structure holding a bitmap\n\n```go\nfunc FromBytes(b []byte) *Bitmap\n```\nFromBytes create a bitmap struct from bytes\n\n```go\nfunc NewBits(nBits int) *Bitmap\n```\nNewBits creates a new bitmap that can address nBits entries. All bits are initially 0 (free).\n\n```go\nfunc NewBytes(nbytes int) *Bitmap\n```\nNewBytes creates a new bitmap of size bytes; it is not in bits to force the caller to have a complete set\n\n```go\nfunc (bm *Bitmap) Clear(location int) error\n```\nClear a specific bit location\n\n```go\nfunc (bm *Bitmap) FirstFree(start int) int\n```\nFirstFree 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.\n\n```go\nfunc (bm *Bitmap) FirstSet() int\n```\nFirstSet returns location of first set bit in the bitmap\n\n```go\nfunc (bm *Bitmap) FreeList() []Contiguous\n```\nFreeList 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\n\n\t\t 1: 2, // 2 free bits at position 1\n\t\t 4: 2, // 2 free bits at position 4\n\t\t 8: 3, // 3 free bits at position 8\n\t\t11: 5  // 5 free bits at position 11\n\t    17: 5  // 5 free bits at position 17\n\t\t23: 1, // 1 free bit at position 23\n\nif you want it in reverse order, just reverse the slice.\n\n```go\nfunc (bm *Bitmap) FromBytes(b []byte)\n```\nFromBytes overwrite the existing map with the contents of the bytes. It is the equivalent of BitmapFromBytes, but uses an existing Bitmap.\n\n```go\nfunc (bm *Bitmap) IsSet(location int) (bool, error)\n```\nIsSet check if a specific bit location is set\n\n```go\nfunc (bm *Bitmap) Set(location int) error\n```\nSet a specific bit location\n\n```go\nfunc (bm *Bitmap) ToBytes() []byte\n```\nToBytes returns raw bytes underlying the bitmap\n\n```go\ntype Contiguous struct {\n\tPosition int\n\tCount    int\n}\n```\nContiguous a position and count of contiguous bits, either free or set\n\n","path":"github.com/ejfkdev/udf/diskkit/util/bitmap","name":"bitmap","synopsis":"","isRedistributable":true}
