// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
* vectors: they are unspecified.
*/
virtual VECTOR* alloc () = 0;
-
+
/**
* Return a vector and indicate
* that it is not going to be
/** @addtogroup Exceptions
* @{ */
-
+
/**
* No more available vectors.
*/
* Conversion to regular pointer.
*/
operator VECTOR* () const;
-
+
/**
* Dereferencing operator.
*/
VECTOR& operator * () const;
-
+
/**
* Dereferencing operator.
*/
* The pointer to the vector.
*/
VECTOR* v;
- };
+ };
};
{
return new VECTOR();
}
-
+
/**
* Return a vector and indicate
* that it is not going to be
* template GrowingVectorMemory<MyVector>::Pool
* GrowingVectorMemory<MyVector>::pool;
* @endcode
- *
+ *
* @author Guido Kanschat, 1999, 2007
*/
template<class VECTOR = dealii::Vector<double> >
* are allocated vectors left.
*/
~GrowingVectorMemory();
-
+
/**
* Return a pointer to a new
* vector. The number of elements
* vectors: they are unspecified.
*/
virtual VECTOR* alloc ();
-
+
/**
* Return a vector and indicate
* that it is not going to be
* not currently in use.
*/
static void release_unused_memory ();
-
+
/**
* Memory consumed by this class
* and all currently allocated
* vectors.
*/
- unsigned int memory_consumption() const;
+ virtual unsigned int memory_consumption() const;
private:
/**
/// Pointer to the storage object
std::vector<entry_type>* data;
};
-
+
/**
* Array of allocated vectors.
*/
static Pool pool;
-
+
/**
* Overall number of
* allocations. Only used for
* for detecting memory leaks.
*/
unsigned int current_alloc;
-
+
/**
* A flag controlling the logging
* of statistics by the
* destructor.
*/
bool log_statistics;
-
+
/**
* Mutex to synchronise access to
* internal data of this object
if (data == 0)
{
data = new std::vector<entry_type>(size);
-
+
for (typename std::vector<entry_type>::iterator i= data->begin();
i != data->end();
++i)
inline
GrowingVectorMemory<VECTOR>::GrowingVectorMemory (const unsigned int initial_size,
const bool log_statistics)
-
+
:
total_alloc(0),
current_alloc(0),
// just allocate a new one
const entry_type t (true, new VECTOR);
pool.data->push_back(t);
-
+
return t.second;
}
delete i->second;
else
new_data.push_back (*i);
-
+
*pool.data = new_data;
}
}