Advertisement
yojimbos_law

silly queue inclusion boolean check

Feb 18th, 2022
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1.  
  2. //assume everything is in the queue.
  3. everything_in_queue = true;
  4. if(n > k){
  5. //in this case, we can't have everything in the queue, so
  6. everything_in_queue = false;
  7. }
  8. else{
  9. //now we have to actually check each thing.
  10. for j from 0 to n-1{
  11. //only do the following until we find something outside the queue.
  12. if( everything_in_queue ){
  13. in_queue = false;
  14. for i from 1 to k{
  15. if(j == buffer_queue[i]){
  16. //we found j in queue slot i.
  17. in_queue = true;
  18. }
  19. }
  20. //now update our understanding of whether the queue is full based on our knowledge of j.
  21. everything_in_queue = everything_in_queue & in_queue;
  22. }
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement