Eneboo - Documentación para desarrolladores
src/hoard/src/heaplayers/experimental/binheap.h
Ir a la documentación de este archivo.
00001 /* -*- C++ -*- */
00002 
00003 #ifndef _BINHEAP_H_
00004 #define _BINHEAP_H_
00005 
00006 #include <stdio.h>
00007 
00008 
00009 template <int Bins[], int NumBins, class Super>
00010 class BinHeap {
00011 public:
00012   
00013   inline void * malloc (size_t sz) {
00014     // Find bin.
00015     int bin = findBin (sz);
00016     void * ptr = myHeaps[bin].malloc (sz);
00017     return ptr;
00018   }
00019   
00020   inline void free (void * ptr) {
00021     size_t sz = Super::size (ptr);
00022     int bin = findBin (sz);
00023     myHeaps[bin].free (ptr);
00024   }
00025 
00026 private:
00027 
00028   inline int findBin (size_t sz) {
00029     int i;
00030     for (i = 0; i < NumBins; i++) {
00031       if (Bins[i] >= sz) {
00032         break;
00033       }
00034     }
00035     return i;
00036   }
00037 
00038   Super myHeaps[NumBins + 1];
00039 
00040 };
00041 
00042 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'