bool spfa() { dist[0] = 0; isInQ[0] = true; que.emplace_back(0); while (!que.empty()) { size_t here = que.front(); que.pop_front(); isInQ[here] = false; visits[here]++; if (visits[here] > n) return true; for (auto edge : G[here]) { int next = edge.second; int weight = edge.first; if (dist[next] > dist[here] + weight) { dist[next] = dist[here] + weight; if (isInQ[next] == false) { que.emplace_back(next); isInQ[next] = true; } } } } return false; }
virtual void AddPacket(shared_ptr<const vector<BYTE>> data, DWORD timestamp, DWORD pts, PacketType type) override { packets.emplace_back(make_shared<const packet_t>(type, timestamp, pts, data)); if (start_recording) { start_recording = false; CreateRecordingHelper(App->fileStream, packets); } if ((*data)[0] != 0x17) return; HandleSaveTimes(pts); keyframes.emplace_back(timestamp, --end(packets)); while (keyframes.size() > 2) { if (((long long)timestamp - keyframes[0].first) < (seconds * 1000) || ((long long)timestamp - keyframes[1].first) < (seconds * 1000)) break; packets.erase(begin(packets), keyframes[1].second); keyframes.erase(begin(keyframes)); } }
void enqueue(const T &x) { Q.emplace(x); while (D.empty() == false && D.back() < x) { D.pop_back(); } D.emplace_back(x); }
void buildParens(deque<string> &list, int leftRem, int rightRem, char *str, int index = 0){ if (leftRem < 0 || rightRem < leftRem) return; if (leftRem == 0 && rightRem == 0){ // we finished all left and right parens list.emplace_back(str); } else { str[index] = '('; // add left paren and recurse buildParens(list, leftRem-1, rightRem, str, index+1); str[index] = ')'; // add right paren and recurse buildParens(list, leftRem, rightRem-1, str, index+1); } }
virtual void AddPacket(BYTE *data, UINT size, DWORD timestamp, DWORD pts, PacketType type) override { packets.emplace_back(make_shared<packet_t>(type, timestamp, pts, vector<BYTE>(data, data + size))); if (data[0] != 0x17) return; HandleSaveTimes(pts); keyframes.emplace_back(timestamp, --end(packets)); while (keyframes.size() > 2) { if (((long long)timestamp - keyframes[0].first) < (seconds * 1000) || ((long long)timestamp - keyframes[1].first) < (seconds * 1000)) break; packets.erase(begin(packets), keyframes[1].second); keyframes.erase(begin(keyframes)); } }