View source code
							
							
						
								Display the source code in std/experimental/allocator/building_blocks/bucketizer.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Struct std.experimental.allocator.building_blocks.bucketizer.Bucketizer
A Bucketizer uses distinct allocators for handling allocations of sizes in
the intervals [min, min + step - 1], [min + step, min + 2 * step - 1],
[min + 2 * step, min + 3 * step - 1], ..., [max - step + 1, max].
						
				struct Bucketizer(Allocator, ulong min, ulong max, ulong step)
				;
						
					
				Bucketizer holds a fixed-size array of allocators and dispatches calls to
them appropriately. The size of the array is (max + 1 - min) / step, which
must be an exact division.
Allocations for sizes smaller than min or larger than max are illegal
for Bucketizer. To handle them separately, Segregator may be of use.
Fields
| Name | Type | Description | 
|---|---|---|
| buckets | Allocator[(max + 1 - min) / step] | The array of allocators is publicly available for e.g. initialization and inspection. | 
Methods
| Name | Description | 
|---|---|
| alignedAllocate | Allocates the requested bytesof memory with specifiedalignment.
    Directs the call to either one of thebucketsallocators. Defined only
    ifAllocatordefinesalignedAllocate. | 
| alignedReallocate | Similar to reallocate, with alignment. Defined only ifAllocatordefinesalignedReallocate. | 
| allocate | Directs the call to either one of the bucketsallocators. | 
| deallocate | This method is only defined if Allocatordefinesdeallocate. | 
| deallocateAll | This method is only defined if all allocators involved define     deallocateAll, and calls it for each bucket in turn. Returnstrueif all
    allocators could deallocate all. | 
| expand | This method allows expansion within the respective bucket range. It succeeds
    if both bandbfall in a range of the form[min + k * step, min + (k + 1) * step - 1]. | 
| goodAllocSize | Rounds up to the maximum size of the bucket in which bytesfalls. | 
| owns | Defined only if Allocatordefinesowns. Finds the owner ofband forwards the call to it. | 
| reallocate | This method allows reallocation within the respective bucket range. If both bandsizefall in a range of the form[min + k *
    step, min + (k + 1) * step - 1], then reallocation is in place. Otherwise,
    reallocation with moving is attempted. | 
| resolveInternalPointer | This method is only defined if all allocators involved define     resolveInternalPointer, and tries it for each bucket in turn. | 
Example
import stdAuthors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.