Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. queue = [pakke1,pakke1,pakke1,pakke3,pakke1,pakke1,pakke1,pakke1,pakke2,pakke1,pakke3,pakke2,pakke1,pakke2,pakke3]
  2. 1 2 3 4 5
  3. snapshot = queue # [pakke1,pakke1,pakke1,pakke3,pakke1,pakke1,pakke1,pakke1,pakke2,pakke1,pakke3,pakke2,pakke1,pakke2,pakke3]
  4.  
  5. tempqueue = [<tom>,<tom>,<tom>]
  6.  
  7. snapshotlength = len(snapshot) #16
  8. index = 1
  9.  
  10. #index-verdi: 14
  11. #1,3,8
  12.  
  13. while index < snapshotlength:
  14.  
  15. IF len(tempqueue[1]) == 0 && snapshot[index] == pakke1:
  16. tempqueue[1] = snapshot[index]
  17. #delete queue[index]
  18.  
  19. IF len(tempqueue[2]) == 0 && snapshot[index] == pakke2:
  20. tempqueue[2] = snapshot[index]
  21. #delete queue[index]
  22.  
  23. IF len(tempqueue[3]) == 0 && snapshot[index] == pakke3:
  24. tempqueue[3] = snapshot[index]
  25. #delete queue[index]
  26.  
  27. IF len(tempqueue) == 3:
  28. index = snapshotlength;
  29. ELSE:
  30. index = index + 1
  31.  
  32.  
  33. sendqueue
  34.  
  35.  
  36. resultat:
  37.  
  38. tempqueue[pakke1,pakke2,pakke3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement