今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Queue implementations
- [Instructor] Let's walk through a few examples to see the methods on the queue in action. To do this, we're going to revisit the check-in list scenario that we used when working with a list. You'll see that this problem is much better suited for a solution that uses a queue. So to start out, I'm going to create a queue that holds guests and I'll name it the checkinQueue. For the queue implementation, I'm going to use an array deque. Okay, so now we have our queue. The first thing that I'm going to do on this queue might seem a little bit odd, but I'm going to attempt to retrieve the element at the head of our empty queue using the remove method. And then from there, I'm just going to print that element or guest to the console. Now watch the behavior here. You'll notice that the method throws an exception because I'm trying to remove the element at the head of an empty queue. Now if I were to switch over this…