Python - Queue With Maximum Length! (Deque)

Опубликовано: 20 Май 2021
на канале: codevev
877
25

#Python #Shorts

If you ever want to make sure your queue doesn't have more than N number of elements, you can use "deque" from "collections" and define "maxlen" on it. This way, whenever a new element gets inserted that will exceed the defined "maxlen" value, the queue will get rid of the oldest element and the new element will appear last in the queue (remember, a queue is implemented using FIFO (First In First Out) structure). And that is how you can use a queue with maximum length!
-------------------------------------------------------------------------------------
Links:
Blog: https://evgenyurubkov.com
Twitter:   / evgenyurubkov  
Instagram:   / evgenyurubkov  
Youtube:    / @codevev  


Смотрите видео Python - Queue With Maximum Length! (Deque) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь codevev 20 Май 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 877 раз и оно понравилось 25 людям.