693 |
if (data) delete[] data; |
if (data) delete[] data; |
694 |
} |
} |
695 |
|
|
696 |
|
/** |
697 |
|
* Returns true if there is at least one free element that could be |
698 |
|
* allocated from the pool with i.e. allocAppend() or allocPreprend(). |
699 |
|
* |
700 |
|
* @see poolHasFreeElements() |
701 |
|
*/ |
702 |
inline bool poolIsEmpty() const { |
inline bool poolIsEmpty() const { |
703 |
return freelist.isEmpty(); |
return freelist.isEmpty(); |
704 |
} |
} |
705 |
|
|
706 |
/** |
/** |
707 |
|
* Returns true if at least the requested amount of free @a elements is |
708 |
|
* currently available for being allocated from the pool with i.e. |
709 |
|
* allocAppend() or allocPreprend(). |
710 |
|
* |
711 |
|
* @see poolIsEmpty() |
712 |
|
*/ |
713 |
|
bool poolHasFreeElements(int elements) { |
714 |
|
for (Iterator it = freelist.first(); it != freelist.end() && elements >= 0; ++it) |
715 |
|
--elements; |
716 |
|
return elements <= 0; |
717 |
|
} |
718 |
|
|
719 |
|
/** |
720 |
* Returns the current size of the pool, that is the amount of |
* Returns the current size of the pool, that is the amount of |
721 |
* pre-allocated elements from the operating system. It equals the |
* pre-allocated elements from the operating system. It equals the |
722 |
* amount of elements given to the constructor unless resizePool() |
* amount of elements given to the constructor unless resizePool() |