| 49 | } |
| 50 | |
| 51 | SQInteger ScriptPriorityQueue::Pop(HSQUIRRELVM vm) |
| 52 | { |
| 53 | if (this->IsEmpty()) { |
| 54 | ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_FAILED); |
| 55 | sq_pushnull(vm); |
| 56 | return 1; |
| 57 | } |
| 58 | |
| 59 | HSQOBJECT item = this->queue.front().second; |
| 60 | std::pop_heap(this->queue.begin(), this->queue.end(), this->comp); |
| 61 | this->queue.pop_back(); |
| 62 | |
| 63 | /* Store the object on the Squirrel stack before releasing it to make sure the ref count can't drop to zero. */ |
| 64 | auto ret = SQConvert::Return<HSQOBJECT>::Set(vm, item); |
| 65 | sq_release(vm, &item); |
| 66 | return ret; |
| 67 | } |
| 68 | |
| 69 | SQInteger ScriptPriorityQueue::Peek(HSQUIRRELVM vm) |
| 70 | { |
no test coverage detected