type AllocationBitmap … var _ … var _ … type bitAllocator … // NewAllocationMap creates an allocation bitmap using the random scan strategy. func NewAllocationMap(max int, rangeSpec string) *AllocationBitmap { … } // NewAllocationMapWithOffset creates an allocation bitmap using a random scan strategy that // allows to pass an offset that divides the allocation bitmap in two blocks. // The first block of values will not be used for random value assigned by the AllocateNext() // method until the second block of values has been exhausted. // The offset value must be always smaller than the bitmap size. func NewAllocationMapWithOffset(max int, rangeSpec string, offset int) *AllocationBitmap { … } // Allocate attempts to reserve the provided item. // Returns true if it was allocated, false if it was already in use func (r *AllocationBitmap) Allocate(offset int) (bool, error) { … } // AllocateNext reserves one of the items from the pool. // (0, false, nil) may be returned if there are no items left. func (r *AllocationBitmap) AllocateNext() (int, bool, error) { … } // Release releases the item back to the pool. Releasing an // unallocated item or an item out of the range is a no-op and // returns no error. func (r *AllocationBitmap) Release(offset int) error { … } const notZero … const wordPower … const wordSize … // ForEach calls the provided function for each allocated bit. The // AllocationBitmap may not be modified while this loop is running. func (r *AllocationBitmap) ForEach(fn func(int)) { … } // Has returns true if the provided item is already allocated and a call // to Allocate(offset) would fail. func (r *AllocationBitmap) Has(offset int) bool { … } // Free returns the count of items left in the range. func (r *AllocationBitmap) Free() int { … } // Snapshot saves the current state of the pool. func (r *AllocationBitmap) Snapshot() (string, []byte) { … } // Restore restores the pool to the previously captured state. func (r *AllocationBitmap) Restore(rangeSpec string, data []byte) error { … } // Destroy cleans up everything on shutdown. func (r *AllocationBitmap) Destroy() { … } type randomScanStrategy … func (rss randomScanStrategy) AllocateBit(allocated *big.Int, max, count int) (int, bool) { … } var _ … type randomScanStrategyWithOffset … func (rss randomScanStrategyWithOffset) AllocateBit(allocated *big.Int, max, count int) (int, bool) { … } var _ …