Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound the number was never allocated ErrNotFound = errors.New("number not allocated") // ErrConflict the number was already allocated ErrConflict = errors.New("number already allocated") // ErrInvalidRange the range is invalid ErrInvalidRange = errors.New("invalid range") // ErrOutOfRange the number is out of range ErrOutOfRange = errors.New("out of range") // ErrRangeFull the range is full ErrRangeFull = errors.New("range full") // ErrInternal something is wrong internally ErrInternal = errors.New("internal error") )
Functions ¶
This section is empty.
Types ¶
type MinMaxAllocator ¶
type MinMaxAllocator struct {
// contains filtered or unexported fields
}
MinMaxAllocator is an allocator over a range [min-max]
func NewMinMaxAllocator ¶
func NewMinMaxAllocator(min, max int) (*MinMaxAllocator, error)
NewMinMaxAllocator creates a new MinMaxAllocator
func (*MinMaxAllocator) Allocate ¶
func (a *MinMaxAllocator) Allocate(i int) (bool, error)
Allocate allocates a given number
func (*MinMaxAllocator) AllocateNext ¶
func (a *MinMaxAllocator) AllocateNext() (int, bool, error)
AllocateNext allocates the first free number
func (*MinMaxAllocator) Free ¶
func (a *MinMaxAllocator) Free() int
Free returns the next free number
func (*MinMaxAllocator) Has ¶
func (a *MinMaxAllocator) Has(i int) bool
Has returns whether the allocator has the given number
func (*MinMaxAllocator) Release ¶
func (a *MinMaxAllocator) Release(i int) error
Release releases the given number
func (*MinMaxAllocator) SetRange ¶
func (a *MinMaxAllocator) SetRange(min, max int) error
SetRange sets the range of the MinMaxAllocator
Click to show internal directories.
Click to hide internal directories.