{"modulePath":"github.com/kmodules/external-storage","version":"v5.2.0+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package allocator\n\n## Variables\n\n```go\nvar (\n\t// ErrNotFound the number was never allocated\n\tErrNotFound = errors.New(\"number not allocated\")\n\t// ErrConflict the number was already allocated\n\tErrConflict = errors.New(\"number already allocated\")\n\t// ErrInvalidRange the range is invalid\n\tErrInvalidRange = errors.New(\"invalid range\")\n\t// ErrOutOfRange the number is out of range\n\tErrOutOfRange = errors.New(\"out of range\")\n\t// ErrRangeFull the range is full\n\tErrRangeFull = errors.New(\"range full\")\n\t// ErrInternal something is wrong internally\n\tErrInternal = errors.New(\"internal error\")\n)\n```\n\n## Types\n\n```go\ntype MinMaxAllocator struct {\n\t// contains filtered or unexported fields\n}\n```\nMinMaxAllocator is an allocator over a range \\[min-max]\n\n```go\nfunc NewMinMaxAllocator(min, max int) (*MinMaxAllocator, error)\n```\nNewMinMaxAllocator creates a new MinMaxAllocator\n\n```go\nfunc (a *MinMaxAllocator) Allocate(i int) (bool, error)\n```\nAllocate allocates a given number\n\n```go\nfunc (a *MinMaxAllocator) AllocateNext() (int, bool, error)\n```\nAllocateNext allocates the first free number\n\n```go\nfunc (a *MinMaxAllocator) Free() int\n```\nFree returns the next free number\n\n```go\nfunc (a *MinMaxAllocator) Has(i int) bool\n```\nHas returns whether the allocator has the given number\n\n```go\nfunc (a *MinMaxAllocator) Release(i int) error\n```\nRelease releases the given number\n\n```go\nfunc (a *MinMaxAllocator) SetRange(min, max int) error\n```\nSetRange sets the range of the MinMaxAllocator\n\n```go\ntype Rangeable interface {\n\tAllocate(int) (bool, error)\n\tAllocateNext() (int, bool, error)\n\tRelease(int) error\n\tHas(int) bool\n\tFree() int\n\tSetRange(min, max int) error\n}\n```\nRangeable is an Interface that can adjust its min/max range. Rangeable should be threadsafe\n\n","path":"github.com/kmodules/external-storage/lib/allocator","name":"allocator","synopsis":"","isRedistributable":true}
