In the C++ language, what does sloc and rloc mean? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
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(); };

15th Oct 2018, 1:31 AM
ManukaServer
ManukaServer - avatar
1 Respuesta
+ 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.
15th Oct 2018, 3:53 AM
Hatsy Rei
Hatsy Rei - avatar