12 #ifndef MFEM_MEM_ALLOC
13 #define MFEM_MEM_ALLOC
15 #include "../config/config.hpp"
21 template <
class Elem,
int Num>
29 template <
class Elem,
int Num>
36 Stack() { TopPart = TopFreePart = NULL; UsedInTop = Num; SSize = 0; }
37 int Size()
const {
return SSize; }
46 template <
class Elem,
int Num>
52 if (TopFreePart == NULL)
58 TopFreePart = (aux = TopFreePart)->Prev;
68 template <
class Elem,
int Num>
74 TopPart = (aux = TopPart)->Prev;
75 aux->
Prev = TopFreePart;
80 return TopPart->
Elements[--UsedInTop];
83 template <
class Elem,
int Num>
87 while (TopPart != NULL)
89 TopPart = (aux = TopPart)->Prev;
92 while (TopFreePart != NULL)
94 TopFreePart = (aux = TopFreePart)->Prev;
101 template <
class Elem,
int Num>
110 template <
class Elem,
int Num>
131 template <
class Elem,
int Num>
139 template <
class Elem,
int Num>
156 template <
class Elem,
int Num>
160 if (UsedMem.Size() > 0)
162 return UsedMem.Pop();
164 if (AllocatedInLast == Num)
171 return &(Last->Elements[AllocatedInLast++]);
174 template <
class Elem,
int Num>
180 template <
class Elem,
int Num>
190 AllocatedInLast = Num;
194 template <
class Elem,
int Num>
198 mfem::Swap(AllocatedInLast, other.AllocatedInLast);
199 UsedMem.Swap(other.UsedMem);
202 template <
class Elem,
int Num>
size_t MemoryUsage() const
void Swap(Stack< Elem, Num > &other)
size_t MemoryUsage() const
StackPart< Elem, Num > * Prev
void Swap(Array< T > &, Array< T > &)
void Swap(MemAlloc< Elem, Num > &other)
MemAllocNode< Elem, Num > * Prev