Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- queue = [pakke1,pakke1,pakke1,pakke3,pakke1,pakke1,pakke1,pakke1,pakke2,pakke1,pakke3,pakke2,pakke1,pakke2,pakke3]
- 1 2 3 4 5
- snapshot = queue # [pakke1,pakke1,pakke1,pakke3,pakke1,pakke1,pakke1,pakke1,pakke2,pakke1,pakke3,pakke2,pakke1,pakke2,pakke3]
- tempqueue = [<tom>,<tom>,<tom>]
- snapshotlength = len(snapshot) #16
- index = 1
- #index-verdi: 14
- #1,3,8
- while index < snapshotlength:
- IF len(tempqueue[1]) == 0 && snapshot[index] == pakke1:
- tempqueue[1] = snapshot[index]
- #delete queue[index]
- IF len(tempqueue[2]) == 0 && snapshot[index] == pakke2:
- tempqueue[2] = snapshot[index]
- #delete queue[index]
- IF len(tempqueue[3]) == 0 && snapshot[index] == pakke3:
- tempqueue[3] = snapshot[index]
- #delete queue[index]
- IF len(tempqueue) == 3:
- index = snapshotlength;
- ELSE:
- index = index + 1
- sendqueue
- resultat:
- tempqueue[pakke1,pakke2,pakke3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement