mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-07-14 23:00:29 +03:00
delete unused class. Merge pages in mempool
This commit is contained in:
parent
f1f815669a
commit
afc2942e37
@ -97,6 +97,16 @@ uint8_t *MemPool::More(std::size_t size)
|
||||
|
||||
void MemPool::Reset()
|
||||
{
|
||||
if (m_pages.size() > 1) {
|
||||
size_t total = 0;
|
||||
for (size_t i = 0; i < m_pages.size(); ++i) {
|
||||
total += m_pages[i]->size;
|
||||
}
|
||||
RemoveAllInColl(m_pages);
|
||||
Page* page = new Page(total);
|
||||
m_pages.push_back(page);
|
||||
}
|
||||
|
||||
m_currPage = 0;
|
||||
current_ = m_pages[0]->mem;
|
||||
}
|
||||
|
@ -70,78 +70,6 @@ private:
|
||||
MemPool &operator=(const MemPool &);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<typename T>
|
||||
class ObjectPoolContiguous
|
||||
{
|
||||
|
||||
public:
|
||||
ObjectPoolContiguous(std::size_t initSize = 100000) :
|
||||
m_size(0), m_actualSize(initSize) {
|
||||
m_vec = (T*) malloc(sizeof(T) * initSize);
|
||||
}
|
||||
|
||||
~ObjectPoolContiguous() {
|
||||
free(m_vec);
|
||||
}
|
||||
|
||||
void Add(T &obj) {
|
||||
if (m_size >= m_actualSize) {
|
||||
//std::cerr << std::endl << "MORE " << m_size << std::endl;
|
||||
m_actualSize *= 2;
|
||||
m_vec = (T*) realloc(m_vec, sizeof(T) * m_actualSize);
|
||||
|
||||
}
|
||||
m_vec[m_size] = obj;
|
||||
++m_size;
|
||||
}
|
||||
|
||||
bool IsEmpty() const {
|
||||
return m_size == 0;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
// vector op
|
||||
size_t GetSize() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
const T& operator[](size_t ind) const {
|
||||
return m_vec[ind];
|
||||
}
|
||||
|
||||
// stack op
|
||||
const T &Get() const {
|
||||
return m_vec[m_size - 1];
|
||||
}
|
||||
|
||||
void Pop() {
|
||||
--m_size;
|
||||
}
|
||||
|
||||
T *GetData() {
|
||||
return m_vec;
|
||||
}
|
||||
|
||||
template<typename ORDERER>
|
||||
void Sort(const ORDERER &orderer) {
|
||||
std::sort(m_vec, m_vec + m_size, orderer);
|
||||
}
|
||||
|
||||
private:
|
||||
T *m_vec;
|
||||
size_t m_size, m_actualSize;
|
||||
|
||||
// no copying
|
||||
ObjectPoolContiguous(const ObjectPoolContiguous &);
|
||||
ObjectPoolContiguous &operator=(const ObjectPoolContiguous &);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user