#include <networkscratch.h>
template<typename T>
class tesseract::NetworkScratch::Stack< T >
Definition at line 219 of file networkscratch.h.
◆ Stack()
◆ ~Stack()
Definition at line 223 of file networkscratch.h.
223 {
224 for (auto data : stack_) {
225 delete data;
226 }
227 }
◆ Borrow()
Definition at line 231 of file networkscratch.h.
231 {
232 std::lock_guard<std::mutex> lock(mutex_);
233 if (stack_top_ == stack_.size()) {
234 stack_.push_back(new T);
235 flags_.push_back(false);
236 }
237 flags_[stack_top_] = true;
238 return stack_[stack_top_++];
239 }
◆ Return()
Definition at line 245 of file networkscratch.h.
245 {
246 std::lock_guard<std::mutex> lock(mutex_);
247
248 int index = stack_top_;
249 while (--index >= 0 && stack_[index] != item) {
250 }
251 if (index >= 0) {
252 flags_[index] = false;
253 }
254 while (stack_top_ > 0 && !flags_[stack_top_ - 1]) {
255 --stack_top_;
256 }
257 }
The documentation for this class was generated from the following file: