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

#include <sorted.h>

Inheritance diagram for pw::allocator::ReverseSortedBucket< BlockType >:
pw::allocator::internal::SortedBucketBase< ReverseSortedBucket< BlockType >, BlockType > pw::allocator::internal::BucketBase< Derived, BlockType_, ItemType_ >

Static Public Member Functions

static constexpr auto MakeAddPredicate (size_t inner_size)
 
- Static Public Member Functions inherited from pw::allocator::internal::BucketBase< Derived, BlockType_, ItemType_ >
template<typename Iterator , typename Predicate >
static Iterator FindPrevIf (Iterator before_first, Iterator last, Predicate predicate)
 
static auto MakeCanAllocPredicate (Layout layout)
 

Additional Inherited Members

- Public Types inherited from pw::allocator::internal::BucketBase< Derived, BlockType_, ItemType_ >
using BlockType = BlockType_
 
using ItemType = ItemType_
 
- Public Member Functions inherited from pw::allocator::internal::BucketBase< Derived, BlockType_, ItemType_ >
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.
 
template<typename Iterator >
constexpr BlockType * GetBlockFromIterator (Iterator iter, Iterator last)
 
template<typename Iterator >
constexpr BlockType * GetBlockFromPrev (Iterator prev, Iterator last)
 
- Static Protected Member Functions inherited from pw::allocator::internal::BucketBase< Derived, BlockType_, ItemType_ >
static ItemType & GetItemFrom (BlockType &block)
 

Detailed Description

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

Container of free blocks sorted in order of decreasing size.

As noted in the base class, this class relies on a forward list. This allows the free blocks to be as small as a single pointer, but makes insertion and lookup O(n) on the number of blocks in the bucket.

Calling RemoveAny() on this bucket will return the largest free block.

Member Function Documentation

◆ MakeAddPredicate()

template<typename BlockType >
static constexpr auto pw::allocator::ReverseSortedBucket< BlockType >::MakeAddPredicate ( size_t  inner_size)
inlinestaticconstexpr

Returns a lambda that tests if the block storing an item has an inner size smaller than the given inner_size.

This lambda can be used with std::find_if and FindPrevIf.


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