t & get_top()
 {
     if(is_empty())
     {
         throw"stack is empty";
     }
     return q1.back();
 }
	void print1() {
		while (1) {
			unique_lock<mutex> lk(mx1);
			cv1.wait(lk);
			double t1;
			double t1=q1.back();
			lock_guard<mutex> guard(mx2);
			while (t1-q2.front()>1) q2.pop_front();
			for (int i=0; i<q1.size(); i++) {
				cout << q2[i] << " " << t1 << endl;
			}
		}
	}
Example #3
0
void pushNewCar(bool greenLight, Car car) {
	if (line1.size() > line2.size()) {
		line2.push(car);
		if (greenLight) {
			while (!line2.empty()) {
				line2.front().passCrossroads();
				line2.pop();
			}
		} else {
			line2.back().waitAtRedLight(2);
		}
	} else {
		line1.push(car);
		if (greenLight) {
			while (!line1.empty()) {
				line1.front().passCrossroads();
				line1.pop();
			}
		} else {
			line1.back().waitAtRedLight(1);
		}
	}
}
 // Get the top element.
 int top() {
     return rse.back();
 }
Example #5
0
int main(){
	que_sym.push({1,"me"});
	printf("%d:%s\n", que_sym.back().id_num, que_sym.back().name);
	return 0;
}
 // Get the top element.
 int top() {
     return q.back();
 }