Pigweed
 
Loading...
Searching...
No Matches
pw::allocator::UnorderedBucket< BlockType > Class Template Reference

#include <unordered.h>

Inheritance diagram for pw::allocator::UnorderedBucket< BlockType >:
pw::allocator::internal::BucketBase< UnorderedBucket< BlockType >, BlockType, UnorderedItem >

Additional Inherited Members

- Public Types inherited from pw::allocator::internal::BucketBase< UnorderedBucket< BlockType >, BlockType, UnorderedItem >
using BlockType = BlockType
 
using ItemType = UnorderedItem
 
- Public Member Functions inherited from pw::allocator::internal::BucketBase< UnorderedBucket< BlockType >, BlockType, UnorderedItem >
constexpr bool empty () const
 Returns whether this buckets contains any free blocks.
 
constexpr size_t max_inner_size () const
 Returns the configured maximum inner size for blocks in this bucket.
 
constexpr void set_max_inner_size (size_t max_inner_size)
 
bool Add (BlockType &block)
 
BlockType * RemoveAny ()
 
bool Remove (BlockType &block)
 
BlockType * RemoveCompatible (Layout layout)
 
void Clear ()
 Removes all blocks from this bucket.
 
constexpr BlockType * GetBlockFromIterator (Iterator iter, Iterator last)
 
constexpr BlockType * GetBlockFromPrev (Iterator prev, Iterator last)
 
- Static Public Member Functions inherited from pw::allocator::internal::BucketBase< UnorderedBucket< BlockType >, BlockType, UnorderedItem >
static Iterator FindPrevIf (Iterator before_first, Iterator last, Predicate predicate)
 
static auto MakeCanAllocPredicate (Layout layout)
 
- Static Protected Member Functions inherited from pw::allocator::internal::BucketBase< UnorderedBucket< BlockType >, BlockType, UnorderedItem >
static ItemTypeGetItemFrom (BlockType &block)
 

Detailed Description

template<typename BlockType>
class pw::allocator::UnorderedBucket< BlockType >

Container of free blocks that use minimal usable space.

The container used to hold the blocks is a singly-linked list. As a result, it is able to store free blocks as small as sizeof(void*). Insertion and removal of an unspecified block is O(1). Removal internal::of a specific block is O(n) since the whole list may need to be walked to find the block. As such, this bucket type is useful for pools of blocks of a single size.


The documentation for this class was generated from the following file: