BitmapAllocator

public struct BitmapAllocator<BitmapType: FixedWidthInteger & UnsignedInteger>:
    BitmapAllocatorProtocol, CustomStringConvertible

An allocator that uses an UnsignedInteger to store the allocated entries allowing upto .bitWidth entries to be allocated.

  • A textual description of the allocator.

    Declaration

    Swift

    public var description: String { get }

    Return Value

    A zero padding binary representation of the bitmap.

  • Declaration

    Swift

    public var entryCount: Int { get }

    Return Value

    The total number of entries that can be allocated.

  • Declaration

    Swift

    public var freeEntryCount: Int { get }

    Return Value

    The number of entries that have not been allocated.

  • Declaration

    Swift

    public var hasSpace: Bool { get }

    Return Value

    A boolean value indicating whether the allocator has unallocated entries.

  • Creates a new, empty allocator.

    Declaration

    Swift

    public init()
  • Allocate the next free entry.

    Declaration

    Swift

    public mutating func allocate() -> Int?

    Return Value

    The next free entry or nil if the allocator is full.

  • Frees the entry allowing it to be reused.

    Precondition

    The entry must be currently allocated.

    Declaration

    Swift

    public mutating func free(entry: Int)

    Parameters

    entry

    The entry index to be freed.