今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Deque objects
- [Instructor] The last collection class that we'll take a look at in this chapter is called a deque. Now the name may look like it says de queue, but it's actually pronounced deque, and it's sort of a hybrid object between a stack and a queue. In fact, the name itself basically means double-ended queue. You can use them to append or pop data from either side, and they are designed to be memory-efficient when accessing them from either end. Deques can be initialized to be either empty or get their initial data from an existing, iterable object, and they can also be specified to have a maximum length. To add data to a deque, you use either the append or append left methods to add items onto the end or the beginning, and similarly, items can be removed using either pop or pop left. Deques also support a rotate function, which can operate in either direction. The rotate function takes a parameter indicating how many items to rotate and defaults to one, so positive numbers will rotate to…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。