0
In the C++ language, what does sloc and rloc mean?
In a Class Queue example, I noticed that sloc and rloc were used but I don’t know what they mean. Does anyone know? Example: class queue { int q(100); int sloc, rloc; public: void init(); void qput(int i); int qget(); };
1 Réponse
+ 6
A brief search online shows that sloc and rloc are most probably integers representing the current/first index of objects within the queue. The queue initializes the two variables to zero, and when an object enters the queue, it is inserted at q[sloc], and then sloc is incremented by 1. When you get an object from the queue, q[rloc] is returned, and rloc is incremented by 1.