31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.10 Memory Allocator ( leda allocator )<br />

1. Definition<br />

An instance A of the data type leda allocator is a memory allocator according to the<br />

C++standard. leda allocator is the standard compliant interface to the <strong>LEDA</strong> memory<br />

management.<br />

#include < <strong>LEDA</strong>/system/allocator.h ><br />

2. Types<br />

Local types are size type, difference type, value type, pointer, reference, const pointer, and<br />

const reference.<br />

template <br />

leda allocator:: rebind<br />

allows the construction of a derived allocator:<br />

leda allocator:: template rebind:: other<br />

is the type leda allocator.<br />

3. Creation<br />

leda allocator A; introduces a variable A of type leda allocator.<br />

4. Operations<br />

pointer A.allocate(size type n, const pointer = 0)<br />

void A.deallocate(pointer p, size type n)<br />

pointer A.address(reference r)<br />

returns a pointer to a newly allocated memory range of<br />

size n ∗ sizeof (T ).<br />

deallocates a memory range of n ∗ sizeof (T ) starting at<br />

p. Precondition: the memory range was obtained via<br />

allocate(n).<br />

returns &r.<br />

const pointer A.address(const reference r)<br />

returns &r.<br />

void A.construct(pointer p, const reference r)<br />

void A.destroy(pointer p)<br />

makes an inplace new new( (void∗)p ) T (r).<br />

destroys the object referenced via p by calling p →<br />

∼T ( ).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!