freelist Class

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Manages a list of memory blocks.

template <std::size_t Sz, class Max>  
class freelist
 : public Max

Parameters

ParameterDescription
SzThe number of elements in the array to be allocated.
MaxThe max class representing the maximum number of elements to be stored in the free list. The max class can be max_none, max_unbounded, max_fixed_size, or max_variable_size.

This template class manages a list of memory blocks of size Sz with the maximum length of the list determined by the max class passed in Max.

Constructors

freelistConstructs an object of type freelist.

Member Functions

popRemoves the first memory block from the free list.
pushAdds a memory block to the list.

Header: <allocators>

Namespace: stdext

Constructs an object of type freelist.

freelist();

Remarks

Removes the first memory block from the free list.

void *pop();

Return Value

Returns a pointer to the memory block removed from the list.

Remarks

The member function returns NULL if the list is empty. Otherwise, it removes the first memory block from the list.

Adds a memory block to the list.

bool push(void* ptr);

Parameters

ParameterDescription
ptrA pointer to the memory block to be added to the free list.

Return Value

true if the full function of the max class returns false; otherwise, the push function returns false.

Remarks

If the full function of the max class returns false, this member function adds the memory block pointed to by ptr to the head of the list.

<allocators>

Show: