next up previous contents index
Next: Memory Allocator ( leda_allocator Up: Simple Data Types Previous: Dynamic Random Variates (

   
Memory Management

LEDA offers an efficient memory management system that is used internally for all node, edge and item types. This system can easily be customized for user defined classes by the ``LEDA_MEMORY" macro. You simply have to add the macro call ``LEDA_MEMORY(T)" to the declaration of a class T. This redefines new and delete operators for type T, such that they allocate and deallocate memory using LEDA's internal memory manager.

struct pair {
  double x;
  double y;

  pair() { x = y = 0; }
  pair(const pair& p) { x = p.x; y = p.y; }

  friend ostream& operator<<(ostream&, const pair&) { ... }
  friend istream& operator>>(istream&, pair&)       { ... }
  friend int compare(const pair& p, const pair& q)  { ... }

  LEDA_MEMORY(pair)

};

dictionary<pair,int> D;



© Copyright 1995-2002, Algorithmic Solutions Software GmbH. All rights reserved.
2002-10-16