pool: use size_t for allocated sizes
This commit is contained in:
parent
1c009b9602
commit
36a80c33a9
15
pool.hpp
15
pool.hpp
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "nocopy.hpp"
|
#include "nocopy.hpp"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class pool : public nocopy {
|
class pool : public nocopy {
|
||||||
@ -33,18 +35,25 @@ namespace util {
|
|||||||
|
|
||||||
node *m_head;
|
node *m_head;
|
||||||
node *m_next;
|
node *m_next;
|
||||||
unsigned int m_capacity;
|
size_t m_capacity;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
pool (unsigned int _capacity);
|
pool (unsigned int _capacity);
|
||||||
~pool ();
|
~pool ();
|
||||||
|
|
||||||
unsigned int capacity (void) const;
|
// Data management
|
||||||
|
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
T* acquire (Args&... args);
|
T* acquire (Args&... args);
|
||||||
|
|
||||||
void release (T *data);
|
void release (T *data);
|
||||||
|
|
||||||
|
size_t capacity (void) const;
|
||||||
|
|
||||||
|
// Indexing
|
||||||
|
size_t index (const T*) const;
|
||||||
|
|
||||||
|
T& operator[] (size_t idx);
|
||||||
|
const T& operator[] (size_t idx) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user