18#include "pw_allocator/bucket/base.h"
19#include "pw_containers/intrusive_forward_list.h"
21namespace pw::allocator {
41template <
typename BlockType>
46 using Base = internal::
47 BucketBase<UnorderedBucket<BlockType>, BlockType,
UnorderedItem>;
55 void DoAdd(BlockType& block) {
57 items_.push_front(*item);
61 BlockType* DoRemoveAny() {
64 return BlockType::FromUsableSpace(&item);
68 const BlockType* DoFindLargest()
const {
69 auto iter = std::max_element(items_.begin(), items_.end(),
Base::Compare);
70 return BlockType::FromUsableSpace(&(*iter));
74 bool DoRemove(BlockType& block) {
79 BlockType* DoRemoveCompatible(
Layout layout) {
84 if (block !=
nullptr) {
85 items_.erase_after(prev);
Definition: intrusive_forward_list.h:91
Definition: unordered.h:44
Definition: unordered.h:32
static constexpr BlockType * GetBlockFromPrev(Iterator prev, Iterator last)
Definition: base.h:195
static bool Compare(const ItemType &item1, const ItemType &item2)
Definition: base.h:178
static auto MakeCanAllocPredicate(Layout layout)
Definition: base.h:169
void Clear()
Removes all blocks from this bucket.
Definition: base.h:134
static ItemType & GetItemFrom(BlockType &block)
Definition: base.h:205
static Iterator FindPrevIf(Iterator before_first, Iterator last, Predicate predicate)
Definition: base.h:150