mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 09:35:32 +00:00
Z3 sources
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
3f9edad676
commit
e9eab22e5c
1186 changed files with 381859 additions and 0 deletions
50
lib/pool.h
Normal file
50
lib/pool.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*++
|
||||
Copyright (c) 2006 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
pool.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Object pool.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2007-02-15.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _POOL_H_
|
||||
#define _POOL_H_
|
||||
|
||||
#include"util.h"
|
||||
#include"vector.h"
|
||||
|
||||
template<typename T>
|
||||
class pool {
|
||||
ptr_vector<T> m_objs;
|
||||
public:
|
||||
~pool() {
|
||||
std::for_each(m_objs.begin(), m_objs.end(), delete_proc<T>());
|
||||
}
|
||||
|
||||
T * mk() {
|
||||
if (m_objs.empty()) {
|
||||
return alloc(T);
|
||||
}
|
||||
else {
|
||||
T * r = m_objs.back();
|
||||
m_objs.pop_back();
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
void recycle(T * obj) {
|
||||
m_objs.push_back(obj);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _POOL_H_ */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue