[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.00,0:00:09.00,Default,,0000,0000,0000,, Dialogue: 0,0:00:09.00,0:00:12.00,Default,,0000,0000,0000,,This presentation is delivered by the Stanford Center for Professional Development. Dialogue: 0,0:00:12.00,0:00:22.00,Default,,0000,0000,0000,, Dialogue: 0,0:00:22.00,0:00:25.00,Default,,0000,0000,0000,,Okay, anything administratively you'd like to ask about? How many people Dialogue: 0,0:00:25.00,0:00:29.00,Default,,0000,0000,0000,,have completed assignment 1, and done the whole thing? Dialogue: 0,0:00:29.00,0:00:32.00,Default,,0000,0000,0000,,All right, you get a gold star. All right, Dialogue: 0,0:00:32.00,0:00:36.00,Default,,0000,0000,0000,,you guys want to be him, is what it is, because this guys is getting to go skiing guilt free. You Dialogue: 0,0:00:36.00,0:00:39.00,Default,,0000,0000,0000,,guys if you're going skiing won't be guilt free, and Dialogue: 0,0:00:39.00,0:00:42.00,Default,,0000,0000,0000,,you'll be working late to finish it off, and he Dialogue: 0,0:00:42.00,0:00:44.00,Default,,0000,0000,0000,,is sleeping easy. Dialogue: 0,0:00:44.00,0:00:47.00,Default,,0000,0000,0000,,How many people have at least one or two of the problems done? Dialogue: 0,0:00:47.00,0:00:51.00,Default,,0000,0000,0000,,Okay, that's a good number. Dialogue: 0,0:00:51.00,0:00:54.00,Default,,0000,0000,0000,,We're still making progress. Dialogue: 0,0:00:54.00,0:00:57.00,Default,,0000,0000,0000,,So I had just started to talk a little about this idea of a template, Dialogue: 0,0:00:57.00,0:01:02.00,Default,,0000,0000,0000,,which is the C++ equivalent of the Java generic, Dialogue: 0,0:01:02.00,0:01:03.00,Default,,0000,0000,0000,,and I Dialogue: 0,0:01:03.00,0:01:07.00,Default,,0000,0000,0000,,want to refresh on the rules about how do you use a template. The thing about templates Dialogue: 0,0:01:07.00,0:01:10.00,Default,,0000,0000,0000,,is they're a very useful and practical Dialogue: 0,0:01:10.00,0:01:11.00,Default,,0000,0000,0000,,component to have in the language, Dialogue: 0,0:01:11.00,0:01:14.00,Default,,0000,0000,0000,,but they do have a little bit of issues with resolve to when you make mistakes Dialogue: 0,0:01:14.00,0:01:17.00,Default,,0000,0000,0000,,with them, kinda having it reported and how you learn about them, and so they can be a Dialogue: 0,0:01:17.00,0:01:21.00,Default,,0000,0000,0000,,little bit of a tripping point despite their vast utility. Dialogue: 0,0:01:21.00,0:01:24.00,Default,,0000,0000,0000,,Let me just remind you about what it means to use a template; is that you use Dialogue: 0,0:01:24.00,0:01:27.00,Default,,0000,0000,0000,,include the interface file as usual. We're trying to use a vector to hold some Dialogue: 0,0:01:27.00,0:01:30.00,Default,,0000,0000,0000,,sequence of things, so we include the vector.H. Dialogue: 0,0:01:30.00,0:01:32.00,Default,,0000,0000,0000,,The name vector Dialogue: 0,0:01:32.00,0:01:36.00,Default,,0000,0000,0000,,by itself without specialization doesn't tell the compiler everything Dialogue: 0,0:01:36.00,0:01:38.00,Default,,0000,0000,0000,,it needs to know. When you're trying to Dialogue: 0,0:01:38.00,0:01:42.00,Default,,0000,0000,0000,,[inaudible] declare a vector, pass a vector as a parameter, return one, and any Dialogue: 0,0:01:42.00,0:01:45.00,Default,,0000,0000,0000,,of those situations where you would have wanted to say it's a vector, you have to Dialogue: 0,0:01:45.00,0:01:48.00,Default,,0000,0000,0000,,say what kind of vector, it's a vector holding character, it's a vector holding Dialogue: 0,0:01:48.00,0:01:49.00,Default,,0000,0000,0000,,location T's, it's Dialogue: 0,0:01:49.00,0:01:50.00,Default,,0000,0000,0000,,a vector holding Dialogue: 0,0:01:50.00,0:01:51.00,Default,,0000,0000,0000,,doubles. Dialogue: 0,0:01:51.00,0:01:54.00,Default,,0000,0000,0000,,And that just applies everywhere you use the name vector, the name vector by itself Dialogue: 0,0:01:54.00,0:01:57.00,Default,,0000,0000,0000,,doesn't mean anything. It always has to have this qualification or specialization on Dialogue: 0,0:01:57.00,0:01:58.00,Default,,0000,0000,0000,,it. Dialogue: 0,0:01:58.00,0:02:02.00,Default,,0000,0000,0000,,And then once that you've committed that to the compiler, the Dialogue: 0,0:02:02.00,0:02:05.00,Default,,0000,0000,0000,,vector from that point really behaves in a type safe manner. A vector Dialogue: 0,0:02:05.00,0:02:08.00,Default,,0000,0000,0000,,character is not the same thing as a vector holding doubles. The Dialogue: 0,0:02:08.00,0:02:11.00,Default,,0000,0000,0000,,compiler keeps those things separate. It doesn't let you co-mingle them. Dialogue: 0,0:02:11.00,0:02:14.00,Default,,0000,0000,0000,,If you expect a vector of care, and you say that as your parameter, Dialogue: 0,0:02:14.00,0:02:17.00,Default,,0000,0000,0000,,then you will have to pass one that has the same element type in it, Dialogue: 0,0:02:17.00,0:02:21.00,Default,,0000,0000,0000,,that passing a vector double is not this same thing, and so trying to put a double Dialogue: 0,0:02:21.00,0:02:23.00,Default,,0000,0000,0000,,into a vector of characters or Dialogue: 0,0:02:23.00,0:02:26.00,Default,,0000,0000,0000,,retrieve an integer out of one that's holding Dialogue: 0,0:02:26.00,0:02:30.00,Default,,0000,0000,0000,,student structures, is going to give you compiler errors, which is really Dialogue: 0,0:02:30.00,0:02:34.00,Default,,0000,0000,0000,,a nice feature for maintaining type safety. Dialogue: 0,0:02:34.00,0:02:38.00,Default,,0000,0000,0000,,So the vector class I had just started talking about, and I'm gonna just kinda pick up Dialogue: 0,0:02:38.00,0:02:42.00,Default,,0000,0000,0000,,and review the things we had started to talk about on Wednesday and go through Dialogue: 0,0:02:42.00,0:02:42.00,Default,,0000,0000,0000,,it, Dialogue: 0,0:02:42.00,0:02:44.00,Default,,0000,0000,0000,,which is what is the vector good for? Dialogue: 0,0:02:44.00,0:02:47.00,Default,,0000,0000,0000,,The vector is good for any Dialogue: 0,0:02:47.00,0:02:50.00,Default,,0000,0000,0000,,collection of things. You need to store a list is kind of the Dialogue: 0,0:02:50.00,0:02:53.00,Default,,0000,0000,0000,,abstraction that it's trying to model. I have a list of students in this class, I have Dialogue: 0,0:02:53.00,0:02:56.00,Default,,0000,0000,0000,,a list of problems that are being assigned, I have Dialogue: 0,0:02:56.00,0:02:59.00,Default,,0000,0000,0000,,a list of classes I'm taking this quarter, you know, whatever those things Dialogue: 0,0:02:59.00,0:03:02.00,Default,,0000,0000,0000,,are, a list of scores on an exam, Dialogue: 0,0:03:02.00,0:03:04.00,Default,,0000,0000,0000,,and the vector Dialogue: 0,0:03:04.00,0:03:06.00,Default,,0000,0000,0000,,manages the needs of all of those kinds of lists. You say what kind of thing Dialogue: 0,0:03:06.00,0:03:09.00,Default,,0000,0000,0000,,you're storing in it. Every element has to be the same type, so that's what I mean by Dialogue: 0,0:03:09.00,0:03:13.00,Default,,0000,0000,0000,,homogeneous, that all the elements are double or they're all students. You Dialogue: 0,0:03:13.00,0:03:15.00,Default,,0000,0000,0000,,can't have doubles and students co-mingle. Dialogue: 0,0:03:15.00,0:03:20.00,Default,,0000,0000,0000,,It's linear in the effect that it kinda lays them out in a line. It indexes them from zero Dialogue: 0,0:03:20.00,0:03:21.00,Default,,0000,0000,0000,,to the size minus 1. Dialogue: 0,0:03:21.00,0:03:25.00,Default,,0000,0000,0000,,Each one has a place in the line and there are no gaps in it, so it actually is Dialogue: 0,0:03:25.00,0:03:26.00,Default,,0000,0000,0000,,sequenced out. Dialogue: 0,0:03:26.00,0:03:30.00,Default,,0000,0000,0000,,And it doesn't - a lot of things that make for a really convenient handling of the Dialogue: 0,0:03:30.00,0:03:33.00,Default,,0000,0000,0000,,list as an abstraction, it knows its size at all time. You can ask it what the Dialogue: 0,0:03:33.00,0:03:36.00,Default,,0000,0000,0000,,size is, it'll tell me how your elements have been stored in it. Now Dialogue: 0,0:03:36.00,0:03:39.00,Default,,0000,0000,0000,,if you ask for an element by index it bounds checks to make sure that you Dialogue: 0,0:03:39.00,0:03:43.00,Default,,0000,0000,0000,,gave it a valid index for the range of size that it's currently holding. Dialogue: 0,0:03:43.00,0:03:45.00,Default,,0000,0000,0000,,It handles all the storage for you. If Dialogue: 0,0:03:45.00,0:03:48.00,Default,,0000,0000,0000,,you put ten elements and to put an eleventh, if it doesn't have space it goes Dialogue: 0,0:03:48.00,0:03:52.00,Default,,0000,0000,0000,,and makes space for you. This all happens without you doing anything explicit, so Dialogue: 0,0:03:52.00,0:03:55.00,Default,,0000,0000,0000,,as you add things, as you remove things, it handles sizing and Dialogue: 0,0:03:55.00,0:03:59.00,Default,,0000,0000,0000,,changing whatever internal storage needs as needed to accommodate what you asked Dialogue: 0,0:03:59.00,0:04:00.00,Default,,0000,0000,0000,,you. Dialogue: 0,0:04:00.00,0:04:03.00,Default,,0000,0000,0000,,It has convenient operations for inserting and removing; where you want to put Dialogue: 0,0:04:03.00,0:04:07.00,Default,,0000,0000,0000,,something in a slot, it will move everything over to make space for it or to shuffle it down to Dialogue: 0,0:04:07.00,0:04:09.00,Default,,0000,0000,0000,,close over that space. Dialogue: 0,0:04:09.00,0:04:11.00,Default,,0000,0000,0000,,It also does what we call a deep copy; a Dialogue: 0,0:04:11.00,0:04:13.00,Default,,0000,0000,0000,,deep copy is Dialogue: 0,0:04:13.00,0:04:17.00,Default,,0000,0000,0000,,sort of a CS term for if I have a vector holding ten numbers, Dialogue: 0,0:04:17.00,0:04:19.00,Default,,0000,0000,0000,,and I assign that to another vector, Dialogue: 0,0:04:19.00,0:04:23.00,Default,,0000,0000,0000,,it really does make a new vector that has the same ten numbers. That deep copy means Dialogue: 0,0:04:23.00,0:04:27.00,Default,,0000,0000,0000,,it's more than some sort of shallow, like they're sharing something. They really are Dialogue: 0,0:04:27.00,0:04:30.00,Default,,0000,0000,0000,,creating a clone of it, so taking that same - however big that vector is, whether it Dialogue: 0,0:04:30.00,0:04:33.00,Default,,0000,0000,0000,,has a hundred or a thousand or two entries, Dialogue: 0,0:04:33.00,0:04:36.00,Default,,0000,0000,0000,,it makes a whole copy, a parallel copy that has Dialogue: 0,0:04:36.00,0:04:38.00,Default,,0000,0000,0000,,the same size and the same entries Dialogue: 0,0:04:38.00,0:04:43.00,Default,,0000,0000,0000,,that was based on taking the original input and reproducing it in a new vector. Dialogue: 0,0:04:43.00,0:04:46.00,Default,,0000,0000,0000,,And that happens when you do assignment from one vector to another, it happens Dialogue: 0,0:04:46.00,0:04:50.00,Default,,0000,0000,0000,,when you do a cast by value of a vector into a function that takes a vector by Dialogue: 0,0:04:50.00,0:04:50.00,Default,,0000,0000,0000,,value, Dialogue: 0,0:04:50.00,0:04:54.00,Default,,0000,0000,0000,,or when you return a vector from a function, so in all those cases it's doing kinda Dialogue: 0,0:04:54.00,0:04:56.00,Default,,0000,0000,0000,,a full deep copy Dialogue: 0,0:04:56.00,0:04:57.00,Default,,0000,0000,0000,,that Dialogue: 0,0:04:57.00,0:05:00.00,Default,,0000,0000,0000,,is unlike those of you had a little experience working with a built in Dialogue: 0,0:05:00.00,0:05:03.00,Default,,0000,0000,0000,,array, know that it doesn't have those behaviors, and that comes as a little bit of Dialogue: 0,0:05:03.00,0:05:06.00,Default,,0000,0000,0000,,a surprise. The vector behaves just like the primitives in the sense that Dialogue: 0,0:05:06.00,0:05:07.00,Default,,0000,0000,0000,,there's no special Dialogue: 0,0:05:07.00,0:05:10.00,Default,,0000,0000,0000,,knowledge you need to know about how it's - Dialogue: 0,0:05:10.00,0:05:14.00,Default,,0000,0000,0000,,the assignment affects other copies of the same vector. Dialogue: 0,0:05:14.00,0:05:17.00,Default,,0000,0000,0000,,So your typical usage is you create an empty vector, you add a new insert; Dialogue: 0,0:05:17.00,0:05:21.00,Default,,0000,0000,0000,,remove to kind of jostle of the contents. You can access the elements Dialogue: 0,0:05:21.00,0:05:25.00,Default,,0000,0000,0000,,once they're in there using member function setat and getat that allow you to Dialogue: 0,0:05:25.00,0:05:27.00,Default,,0000,0000,0000,,change the value of the location, or get the value. Dialogue: 0,0:05:27.00,0:05:31.00,Default,,0000,0000,0000,,There's also an operator bracket. We'll see how you can actually just use the Dialogue: 0,0:05:31.00,0:05:34.00,Default,,0000,0000,0000,,syntax of the vector name and then the bracket with the index to access a Dialogue: 0,0:05:34.00,0:05:35.00,Default,,0000,0000,0000,,particular element, Dialogue: 0,0:05:35.00,0:05:37.00,Default,,0000,0000,0000,,useful for all Dialogue: 0,0:05:37.00,0:05:39.00,Default,,0000,0000,0000,,sorts of things. Dialogue: 0,0:05:39.00,0:05:41.00,Default,,0000,0000,0000,,Question here? Dialogue: 0,0:05:41.00,0:05:43.00,Default,,0000,0000,0000,,Student:Yeah, can you make a multi-dimensional vector? Instructor Dialogue: 0,0:05:43.00,0:05:47.00,Default,,0000,0000,0000,,(Julie Zelenski):You can make a vector or vectors. The next class I'll talk about is a grid, which is kind of just a tooty thing that is Dialogue: 0,0:05:47.00,0:05:47.00,Default,,0000,0000,0000,,already built, Dialogue: 0,0:05:47.00,0:05:50.00,Default,,0000,0000,0000,,and you can also build vectors of vectors, and vectors Dialogue: 0,0:05:50.00,0:05:53.00,Default,,0000,0000,0000,,of vectors of vectors to build to the higher and higher dimensions. And there's a Dialogue: 0,0:05:53.00,0:05:56.00,Default,,0000,0000,0000,,little bit more syntax involved in doing that, but it [inaudible] the same basic functionality Dialogue: 0,0:05:56.00,0:06:00.00,Default,,0000,0000,0000,,kind of applies in higher dimension. Dialogue: 0,0:06:00.00,0:06:03.00,Default,,0000,0000,0000,,So this is the basic interface of the vector, Dialogue: 0,0:06:03.00,0:06:05.00,Default,,0000,0000,0000,,supplied as a template, so Dialogue: 0,0:06:05.00,0:06:09.00,Default,,0000,0000,0000,,all the way through it, it refers to elem type as what you get Dialogue: 0,0:06:09.00,0:06:13.00,Default,,0000,0000,0000,,at, what you set at, what you add and you insert all of the kind of values that are Dialogue: 0,0:06:13.00,0:06:14.00,Default,,0000,0000,0000,,going in and out of that Dialogue: 0,0:06:14.00,0:06:15.00,Default,,0000,0000,0000,,vector are Dialogue: 0,0:06:15.00,0:06:19.00,Default,,0000,0000,0000,,left using this place holder rather than saying it's explicitly a double or a Dialogue: 0,0:06:19.00,0:06:22.00,Default,,0000,0000,0000,,string or something, making no commitment about that, just leaving it open. And then Dialogue: 0,0:06:22.00,0:06:25.00,Default,,0000,0000,0000,,that template typed in elem type is the way that the whole class is introduced to Dialogue: 0,0:06:25.00,0:06:25.00,Default,,0000,0000,0000,,say Dialogue: 0,0:06:25.00,0:06:30.00,Default,,0000,0000,0000,,this is a pattern from which you can create a lot of different vector classes. Dialogue: 0,0:06:30.00,0:06:33.00,Default,,0000,0000,0000,,Let me show you a little something on the next slide that helps to Dialogue: 0,0:06:33.00,0:06:34.00,Default,,0000,0000,0000,,point this out. Dialogue: 0,0:06:34.00,0:06:38.00,Default,,0000,0000,0000,,So here I have, in blue, put all the places where the elem type shows up. I Dialogue: 0,0:06:38.00,0:06:42.00,Default,,0000,0000,0000,,put the type name parameter introduced, and it says within the body of the class I'm using Dialogue: 0,0:06:42.00,0:06:44.00,Default,,0000,0000,0000,,elem type as a place Dialogue: 0,0:06:44.00,0:06:47.00,Default,,0000,0000,0000,,holder, and the four places it's showing up here, the getat the setat the add and Dialogue: 0,0:06:47.00,0:06:48.00,Default,,0000,0000,0000,,the insert, Dialogue: 0,0:06:48.00,0:06:53.00,Default,,0000,0000,0000,,that when I go to create a vector as a client, I'll say vector of double. Dialogue: 0,0:06:53.00,0:06:56.00,Default,,0000,0000,0000,,Every place where there was elem type Dialogue: 0,0:06:56.00,0:06:57.00,Default,,0000,0000,0000,, Dialogue: 0,0:06:57.00,0:07:01.00,Default,,0000,0000,0000,,and on the vector name itself has been annotated or specialized to show Dialogue: 0,0:07:01.00,0:07:04.00,Default,,0000,0000,0000,,that what's really going in out of this thing is double. Dialogue: 0,0:07:04.00,0:07:08.00,Default,,0000,0000,0000,,So this now created a class vector, angle bracket, double. Dialogue: 0,0:07:08.00,0:07:12.00,Default,,0000,0000,0000,,The constructor and the destructor match the class name now, and the getat, the setat, Dialogue: 0,0:07:12.00,0:07:13.00,Default,,0000,0000,0000,,the add, the insert, Dialogue: 0,0:07:13.00,0:07:16.00,Default,,0000,0000,0000,,all have been locked down. We've made that commitment, we said what we're Dialogue: 0,0:07:16.00,0:07:18.00,Default,,0000,0000,0000,,storing here really is vectors of Dialogue: 0,0:07:18.00,0:07:22.00,Default,,0000,0000,0000,,doubles, and that means that the add number function for vector double takes Dialogue: 0,0:07:22.00,0:07:23.00,Default,,0000,0000,0000,,a double parameter. Dialogue: 0,0:07:23.00,0:07:26.00,Default,,0000,0000,0000,,The getat returns a double value, Dialogue: 0,0:07:26.00,0:07:30.00,Default,,0000,0000,0000,,and that way once the compiler has done this transformation Dialogue: 0,0:07:30.00,0:07:33.00,Default,,0000,0000,0000,,that subsequent usage of that vector double variable Dialogue: 0,0:07:33.00,0:07:37.00,Default,,0000,0000,0000,,will be consistent with this filling in of the placeholder, Dialogue: 0,0:07:37.00,0:07:40.00,Default,,0000,0000,0000,,so it doesn't actually get confused about other types of Dialogue: 0,0:07:40.00,0:07:40.00,Default,,0000,0000,0000,,vectors you may have Dialogue: 0,0:07:40.00,0:07:45.00,Default,,0000,0000,0000,,been creating or working with. Dialogue: 0,0:07:45.00,0:07:50.00,Default,,0000,0000,0000,,Question? [Inaudible] No, these empty functions are really just a convenience off of size. You could Dialogue: 0,0:07:50.00,0:07:52.00,Default,,0000,0000,0000,,always check size equals zero, Dialogue: 0,0:07:52.00,0:07:54.00,Default,,0000,0000,0000,,and so it actually doesn't really add anything to the interface. Dialogue: 0,0:07:54.00,0:07:58.00,Default,,0000,0000,0000,,It just turns out you do that so often in many situations, you want to know if Dialogue: 0,0:07:58.00,0:07:59.00,Default,,0000,0000,0000,,this thing is totally empty, Dialogue: 0,0:07:59.00,0:08:03.00,Default,,0000,0000,0000,,that as a convenience it offers two different ways to get at that same information. So you're Dialogue: 0,0:08:03.00,0:08:04.00,Default,,0000,0000,0000,,totally right, it's redundant. Dialogue: 0,0:08:04.00,0:08:08.00,Default,,0000,0000,0000,,Sometimes you'll see that for example the standard template library has a bunch of Dialogue: 0,0:08:08.00,0:08:09.00,Default,,0000,0000,0000,,the same things. The string has Dialogue: 0,0:08:09.00,0:08:13.00,Default,,0000,0000,0000,,a length number function. It also has a size number function. They do exactly the same thing. It's Dialogue: 0,0:08:13.00,0:08:16.00,Default,,0000,0000,0000,,just because sometimes people can remember size, sometimes people remember length. There's Dialogue: 0,0:08:16.00,0:08:17.00,Default,,0000,0000,0000,,also an empty - Dialogue: 0,0:08:17.00,0:08:19.00,Default,,0000,0000,0000,,it's not called is empty, but it's just empty. The Dialogue: 0,0:08:19.00,0:08:22.00,Default,,0000,0000,0000,,[inaudible] is the length or size zero, and so all of those things are kind of written in Dialogue: 0,0:08:22.00,0:08:23.00,Default,,0000,0000,0000,,terms of each other, Dialogue: 0,0:08:23.00,0:08:25.00,Default,,0000,0000,0000,,but they Dialogue: 0,0:08:25.00,0:08:28.00,Default,,0000,0000,0000,,allow different ways to get at the same information. Dialogue: 0,0:08:28.00,0:08:30.00,Default,,0000,0000,0000,,Anything Dialogue: 0,0:08:30.00,0:08:32.00,Default,,0000,0000,0000,,else? You got a question? Here we go. Dialogue: 0,0:08:32.00,0:08:34.00,Default,,0000,0000,0000,,Is there a remove all method? Dialogue: 0,0:08:34.00,0:08:39.00,Default,,0000,0000,0000,,There is actually a clear method, and I should have put that up there. Actually, I think Dialogue: 0,0:08:39.00,0:08:42.00,Default,,0000,0000,0000,,there's a few. In each of these cases I've excerpted a little bit for the most Dialogue: 0,0:08:42.00,0:08:45.00,Default,,0000,0000,0000,,mainstream operations, but there is a clear operation that takes no arguments, Dialogue: 0,0:08:45.00,0:08:46.00,Default,,0000,0000,0000,,returns no argument, that just Dialogue: 0,0:08:46.00,0:08:55.00,Default,,0000,0000,0000,,takes the vector to an empty state. Dialogue: 0,0:08:55.00,0:08:56.00,Default,,0000,0000,0000,,So here's a little bit of Dialogue: 0,0:08:56.00,0:08:56.00,Default,,0000,0000,0000,,code Dialogue: 0,0:08:56.00,0:09:00.00,Default,,0000,0000,0000,,that shows some of the common use of vector and how you might do stuff with it Dialogue: 0,0:09:00.00,0:09:03.00,Default,,0000,0000,0000,,that just gets you familiar with, okay, what does the syntax look like? Dialogue: 0,0:09:03.00,0:09:07.00,Default,,0000,0000,0000,,So I'll look at this top function together, this is make random vector. You give it a Dialogue: 0,0:09:07.00,0:09:10.00,Default,,0000,0000,0000,,parameter, which is the size, and it will fill a vector of integers with a sequence Dialogue: 0,0:09:10.00,0:09:15.00,Default,,0000,0000,0000,,of random numbers up to that size. You say I'd like a length ten vector filled with Dialogue: 0,0:09:15.00,0:09:16.00,Default,,0000,0000,0000,,random numbers, Dialogue: 0,0:09:16.00,0:09:18.00,Default,,0000,0000,0000,,it'll make a ten number vector Dialogue: 0,0:09:18.00,0:09:19.00,Default,,0000,0000,0000,,stuffing in Dialogue: 0,0:09:19.00,0:09:23.00,Default,,0000,0000,0000,,random numbers generated using the random library here. Dialogue: 0,0:09:23.00,0:09:26.00,Default,,0000,0000,0000,,So you'll see the declaration here, so I included vector [inaudible], the compiler knew what Dialogue: 0,0:09:26.00,0:09:29.00,Default,,0000,0000,0000,,I was using. I Dialogue: 0,0:09:29.00,0:09:30.00,Default,,0000,0000,0000,,specialized Dialogue: 0,0:09:30.00,0:09:32.00,Default,,0000,0000,0000,,when I declared that vector, Dialogue: 0,0:09:32.00,0:09:36.00,Default,,0000,0000,0000,,and so the constructor for vector creates a new empty vector of Dialogue: 0,0:09:36.00,0:09:38.00,Default,,0000,0000,0000,,that type, in this case vector of integer, Dialogue: 0,0:09:38.00,0:09:42.00,Default,,0000,0000,0000,,and then numbers.add sticking in a bunch of numbers, and then I'm returning it. Dialogue: 0,0:09:42.00,0:09:46.00,Default,,0000,0000,0000,,So it's totally valid to actually return a vector as the return value coming out of Dialogue: 0,0:09:46.00,0:09:47.00,Default,,0000,0000,0000,,a function. Dialogue: 0,0:09:47.00,0:09:48.00,Default,,0000,0000,0000,,It'll take that, Dialogue: 0,0:09:48.00,0:09:52.00,Default,,0000,0000,0000,,however many numbers I put in there, ten length vector, Dialogue: 0,0:09:52.00,0:09:53.00,Default,,0000,0000,0000,,and make a full copy of it. Dialogue: 0,0:09:53.00,0:09:56.00,Default,,0000,0000,0000,,And then when I'm down here and I'm saying nums equals make random vector, it actually Dialogue: 0,0:09:56.00,0:09:57.00,Default,,0000,0000,0000,,copied Dialogue: 0,0:09:57.00,0:09:59.00,Default,,0000,0000,0000,,that ten number vector Dialogue: 0,0:09:59.00,0:10:03.00,Default,,0000,0000,0000,,into the variable beings stored in main. So now I have a ten number Dialogue: 0,0:10:03.00,0:10:04.00,Default,,0000,0000,0000,,thing with some random contents. Dialogue: 0,0:10:04.00,0:10:07.00,Default,,0000,0000,0000,,The next thing I did with it was pass it to another routine that was going to print Dialogue: 0,0:10:07.00,0:10:08.00,Default,,0000,0000,0000,,it, Dialogue: 0,0:10:08.00,0:10:11.00,Default,,0000,0000,0000,,and there I am getting that vector, and this time I'm Dialogue: 0,0:10:11.00,0:10:12.00,Default,,0000,0000,0000,,accessing it in here Dialogue: 0,0:10:12.00,0:10:14.00,Default,,0000,0000,0000,,by reference. Dialogue: 0,0:10:14.00,0:10:18.00,Default,,0000,0000,0000,,This is just to show you that in typical because of the deep copying semantics it Dialogue: 0,0:10:18.00,0:10:20.00,Default,,0000,0000,0000,,does mean if I didn't pass by reference, it means the Dialogue: 0,0:10:20.00,0:10:25.00,Default,,0000,0000,0000,,full contents of the vector would get copied when I passed it to some function. Dialogue: 0,0:10:25.00,0:10:26.00,Default,,0000,0000,0000,,There's no Dialogue: 0,0:10:26.00,0:10:30.00,Default,,0000,0000,0000,,harm in that per se, other than the fact that it can get inefficient, especially as the Dialogue: 0,0:10:30.00,0:10:33.00,Default,,0000,0000,0000,,vector gets larger, it has hundreds and thousands of entries, Dialogue: 0,0:10:33.00,0:10:34.00,Default,,0000,0000,0000,,that making a full copy of those Dialogue: 0,0:10:34.00,0:10:38.00,Default,,0000,0000,0000,,can have some overall efficiency effects on the program. Dialogue: 0,0:10:38.00,0:10:40.00,Default,,0000,0000,0000,,Passing by reference means it didn't really copy; Dialogue: 0,0:10:40.00,0:10:44.00,Default,,0000,0000,0000,,it just kinda used the copy that was out here by reference, so reaching Dialogue: 0,0:10:44.00,0:10:47.00,Default,,0000,0000,0000,,out and accessing it out of [inaudible]. Dialogue: 0,0:10:47.00,0:10:51.00,Default,,0000,0000,0000,,So in here using the size to know how many elements are in the vector, Dialogue: 0,0:10:51.00,0:10:54.00,Default,,0000,0000,0000,,and then this is what's called an overloaded operator, that the Dialogue: 0,0:10:54.00,0:10:57.00,Default,,0000,0000,0000,,square brackets that you have seen in the past, user array access and the Dialogue: 0,0:10:57.00,0:10:59.00,Default,,0000,0000,0000,,languages you know, Dialogue: 0,0:10:59.00,0:11:01.00,Default,,0000,0000,0000,,can be applied to the vector, Dialogue: 0,0:11:01.00,0:11:05.00,Default,,0000,0000,0000,,and it uses the same sort of syntax that we put an integer in that tells you what index and Dialogue: 0,0:11:05.00,0:11:08.00,Default,,0000,0000,0000,,indices from zero to size minus one are the valid range for Dialogue: 0,0:11:08.00,0:11:12.00,Default,,0000,0000,0000,,the vector, and accessed that integer and printed it out. Dialogue: 0,0:11:12.00,0:11:15.00,Default,,0000,0000,0000,,So anything you would have done on any kind of array, Dialogue: 0,0:11:15.00,0:11:18.00,Default,,0000,0000,0000,,reading a bunch of contents from a file, Dialogue: 0,0:11:18.00,0:11:21.00,Default,,0000,0000,0000,,printing these things out, rearranging them into sorted order, inserting Dialogue: 0,0:11:21.00,0:11:22.00,Default,,0000,0000,0000,,something into sorted order, Dialogue: 0,0:11:22.00,0:11:24.00,Default,,0000,0000,0000,,all those things are Dialogue: 0,0:11:24.00,0:11:28.00,Default,,0000,0000,0000,,operations that work very cleanly when mapped onto what the vector provides. One Dialogue: 0,0:11:28.00,0:11:31.00,Default,,0000,0000,0000,,of the really nice things is unlike most array, Dialogue: 0,0:11:31.00,0:11:33.00,Default,,0000,0000,0000,,like the built in array of C++, Dialogue: 0,0:11:33.00,0:11:36.00,Default,,0000,0000,0000,,you don't have to know in advance how big the vector's gonna be, it just grows Dialogue: 0,0:11:36.00,0:11:37.00,Default,,0000,0000,0000,,on demand. Dialogue: 0,0:11:37.00,0:11:42.00,Default,,0000,0000,0000,,So if you were reading a bunch of numbers from a file, like you are in your assignment 1, Dialogue: 0,0:11:42.00,0:11:45.00,Default,,0000,0000,0000,,you don't have to have figured out ahead of time how many numbers will be there Dialogue: 0,0:11:45.00,0:11:48.00,Default,,0000,0000,0000,,so that I can allocate the storage and set it aside. You just keep calling Dialogue: 0,0:11:48.00,0:11:50.00,Default,,0000,0000,0000,,v.dot add on your vector, Dialogue: 0,0:11:50.00,0:11:51.00,Default,,0000,0000,0000,,and as needed it's just making space. Dialogue: 0,0:11:51.00,0:11:55.00,Default,,0000,0000,0000,,So if there's ten numbers in the file, there's a hundred, there's a million, Dialogue: 0,0:11:55.00,0:11:57.00,Default,,0000,0000,0000,,it will just make the space on demand Dialogue: 0,0:11:57.00,0:12:05.00,Default,,0000,0000,0000,,and you don't have to do anything special to get that access. Question? [Inaudible] The square brackets. No, the [inaudible]. Oh, the Dialogue: 0,0:12:05.00,0:12:07.00,Default,,0000,0000,0000,,angle Dialogue: 0,0:12:07.00,0:12:11.00,Default,,0000,0000,0000,,brackets. Yeah, they turn the side Dialogue: 0,0:12:11.00,0:12:14.00,Default,,0000,0000,0000,,of it and then - no? No, no. The angle brackets are used in this case just for the vector Dialogue: 0,0:12:14.00,0:12:15.00,Default,,0000,0000,0000,,specialization. Dialogue: 0,0:12:15.00,0:12:18.00,Default,,0000,0000,0000,,The square brackets here are being used for - Dialogue: 0,0:12:18.00,0:12:23.00,Default,,0000,0000,0000,,I'm accessing a particular member out of the array by index. [Inaudible] Dialogue: 0,0:12:23.00,0:12:26.00,Default,,0000,0000,0000,,So yeah, what happens in - so if you look at make random vector, Dialogue: 0,0:12:26.00,0:12:30.00,Default,,0000,0000,0000,,it created an empty vector, so the typical usage [inaudible] is you create it empty Dialogue: 0,0:12:30.00,0:12:32.00,Default,,0000,0000,0000,,and then you add things to grow it. Dialogue: 0,0:12:32.00,0:12:36.00,Default,,0000,0000,0000,,So you actually never in here actually have to say how big it's going to be. It Dialogue: 0,0:12:36.00,0:12:38.00,Default,,0000,0000,0000,,just - on demand as I call Dialogue: 0,0:12:38.00,0:12:41.00,Default,,0000,0000,0000,,numbers.add, it got one bigger each time through that loop, and if I did that Dialogue: 0,0:12:41.00,0:12:44.00,Default,,0000,0000,0000,,100 times, that'll have a hundred entry vector. Dialogue: 0,0:12:44.00,0:12:45.00,Default,,0000,0000,0000,,So there isn't actually a mechanism where you say Dialogue: 0,0:12:45.00,0:12:48.00,Default,,0000,0000,0000,,make it a hundred in advance. You will add a hundred things; it will have length Dialogue: 0,0:12:48.00,0:12:50.00,Default,,0000,0000,0000,,a hundred, Dialogue: 0,0:12:50.00,0:12:53.00,Default,,0000,0000,0000,,if you inserted a hundred things. The add me insert both Dialogue: 0,0:12:53.00,0:12:58.00,Default,,0000,0000,0000,,cause the size of the vector to go up by one, remove caused to go down by one. [Inaudible] brackets Dialogue: 0,0:12:58.00,0:12:59.00,Default,,0000,0000,0000,,to Dialogue: 0,0:12:59.00,0:13:02.00,Default,,0000,0000,0000,,access a specific element and write to it Dialogue: 0,0:13:02.00,0:13:07.00,Default,,0000,0000,0000,,and it's not yet at the - will it automatically fill in [inaudible]? No, it will not, so Dialogue: 0,0:13:07.00,0:13:12.00,Default,,0000,0000,0000,,the sub - the square brackets can only access things that are in the vector already. So you can Dialogue: 0,0:13:12.00,0:13:15.00,Default,,0000,0000,0000,,overwrite it if it's there, but if you have a ten-member vector, and you go to Dialogue: 0,0:13:15.00,0:13:17.00,Default,,0000,0000,0000,,say V sub 20, Dialogue: 0,0:13:17.00,0:13:18.00,Default,,0000,0000,0000,,it will not sort of Dialogue: 0,0:13:18.00,0:13:21.00,Default,,0000,0000,0000,,invent the ten members in between there and make that space. So the things that are Dialogue: 0,0:13:21.00,0:13:24.00,Default,,0000,0000,0000,,valid to access to read from are the same ones that are valid to write to, so you Dialogue: 0,0:13:24.00,0:13:25.00,Default,,0000,0000,0000,,can use the square Dialogue: 0,0:13:25.00,0:13:29.00,Default,,0000,0000,0000,,bracket on either side of the assignment operator to read or to write, but it has Dialogue: 0,0:13:29.00,0:13:31.00,Default,,0000,0000,0000,,to still be something that's already in there. If you really want to put Dialogue: 0,0:13:31.00,0:13:34.00,Default,,0000,0000,0000,,a hundred zeros into it, then you need to write a loop that puts a hundred zeros into Dialogue: 0,0:13:34.00,0:13:36.00,Default,,0000,0000,0000,,it Dialogue: 0,0:13:36.00,0:13:39.00,Default,,0000,0000,0000,,using Dialogue: 0,0:13:39.00,0:13:40.00,Default,,0000,0000,0000,, Dialogue: 0,0:13:40.00,0:13:44.00,Default,,0000,0000,0000,,add. Way in the back. [Inaudible] Only for efficiency in Dialogue: 0,0:13:44.00,0:13:47.00,Default,,0000,0000,0000,,this case. I'm not changing it, so if I Dialogue: 0,0:13:47.00,0:13:50.00,Default,,0000,0000,0000,,was planning on going in here and multiplying everything by two or something, Dialogue: 0,0:13:50.00,0:13:53.00,Default,,0000,0000,0000,,I would do that pass by reference to see those changes permanently affected. This Dialogue: 0,0:13:53.00,0:13:56.00,Default,,0000,0000,0000,,actually isn't making any changes to the vector, it's just reading the contents of it, Dialogue: 0,0:13:56.00,0:13:59.00,Default,,0000,0000,0000,,so it could be pass by value and have the same Dialogue: 0,0:13:59.00,0:14:03.00,Default,,0000,0000,0000,,effect, but I wouldn't see any change in the program, it would just run a little slower Dialogue: 0,0:14:03.00,0:14:04.00,Default,,0000,0000,0000,,if I did that. Dialogue: 0,0:14:04.00,0:14:07.00,Default,,0000,0000,0000,,We will typically though - you will see that kinda just by Dialogue: 0,0:14:07.00,0:14:09.00,Default,,0000,0000,0000,,habit we will almost always pass our Dialogue: 0,0:14:09.00,0:14:11.00,Default,,0000,0000,0000,,collections by reference, Dialogue: 0,0:14:11.00,0:14:14.00,Default,,0000,0000,0000,,because of the concern for efficiency in the long run. Dialogue: 0,0:14:14.00,0:14:17.00,Default,,0000,0000,0000,,So it - even though we don't plan on changing it, Dialogue: 0,0:14:17.00,0:14:21.00,Default,,0000,0000,0000,,we'll use that to save ourselves some Dialogue: 0,0:14:21.00,0:14:24.00,Default,,0000,0000,0000,,time. Anything about Dialogue: 0,0:14:24.00,0:14:28.00,Default,,0000,0000,0000,,vector? Dialogue: 0,0:14:28.00,0:14:29.00,Default,,0000,0000,0000,,[Inaudible] Dialogue: 0,0:14:29.00,0:14:32.00,Default,,0000,0000,0000,,The second to the last line before printing, Dialogue: 0,0:14:32.00,0:14:35.00,Default,,0000,0000,0000,,the one right here where I'm going the - so this is declaring vector [inaudible], so Dialogue: 0,0:14:35.00,0:14:37.00,Default,,0000,0000,0000,,making the new variable, and it's assigning it Dialogue: 0,0:14:37.00,0:14:41.00,Default,,0000,0000,0000,,the return value from calling the make random vector function. So it's actually Dialogue: 0,0:14:41.00,0:14:43.00,Default,,0000,0000,0000,,declaring and assigning it in one step Dialogue: 0,0:14:43.00,0:14:46.00,Default,,0000,0000,0000,,where that assignment caused a function to be called that stuffed it full of random Dialogue: 0,0:14:46.00,0:14:50.00,Default,,0000,0000,0000,,numbers and returned it. Ten in that case means what? Dialogue: 0,0:14:50.00,0:14:54.00,Default,,0000,0000,0000,,Ten in this case is just the size. It's the [inaudible] Dialogue: 0,0:14:54.00,0:14:56.00,Default,,0000,0000,0000,,make me a random vector containing ten values, Dialogue: 0,0:14:56.00,0:14:59.00,Default,,0000,0000,0000,,so that's - the ten in this case is just how many things to put in the array. Dialogue: 0,0:14:59.00,0:15:01.00,Default,,0000,0000,0000,,[Inaudible] Dialogue: 0,0:15:01.00,0:15:04.00,Default,,0000,0000,0000,,Well it will make ten random numbers and stick them into the Dialogue: 0,0:15:04.00,0:15:08.00,Default,,0000,0000,0000,,vector, so when you get back you'll have vector of size ten that has ten random Dialogue: 0,0:15:08.00,0:15:09.00,Default,,0000,0000,0000,,entries in it. Dialogue: 0,0:15:09.00,0:15:13.00,Default,,0000,0000,0000,,If I said a hundred I'd get a hundred random entries. [Inaudible] function, which library has it? It is in random.H, Dialogue: 0,0:15:13.00,0:15:14.00,Default,,0000,0000,0000,,so Dialogue: 0,0:15:14.00,0:15:17.00,Default,,0000,0000,0000,, Dialogue: 0,0:15:17.00,0:15:19.00,Default,,0000,0000,0000,,a lower Dialogue: 0,0:15:19.00,0:15:27.00,Default,,0000,0000,0000,,case random.H, which is R cs1061. Okay. Now Dialogue: 0,0:15:27.00,0:15:29.00,Default,,0000,0000,0000,,let me Dialogue: 0,0:15:29.00,0:15:33.00,Default,,0000,0000,0000,,reinforce this idea that templates are type safe, and that if you misuse them Dialogue: 0,0:15:33.00,0:15:34.00,Default,,0000,0000,0000,, Dialogue: 0,0:15:34.00,0:15:36.00,Default,,0000,0000,0000,,you will get errors from the complier Dialogue: 0,0:15:36.00,0:15:39.00,Default,,0000,0000,0000,,that help you to alert yourself to the mistakes that you've made. If I Dialogue: 0,0:15:39.00,0:15:41.00,Default,,0000,0000,0000,,make a vector Dialogue: 0,0:15:41.00,0:15:44.00,Default,,0000,0000,0000,,specialized to hold [inaudible] is really an integer vector, I make a vector Dialogue: 0,0:15:44.00,0:15:47.00,Default,,0000,0000,0000,,to hold strings I call words, that Dialogue: 0,0:15:47.00,0:15:51.00,Default,,0000,0000,0000,,I could add integers into the first one, I could add words to the second one, but I can't Dialogue: 0,0:15:51.00,0:15:54.00,Default,,0000,0000,0000,,cross those lines. If I try to take nums Dialogue: 0,0:15:54.00,0:15:55.00,Default,,0000,0000,0000,,and add to it the string banana, Dialogue: 0,0:15:55.00,0:15:57.00,Default,,0000,0000,0000,,it will not compile, Dialogue: 0,0:15:57.00,0:15:59.00,Default,,0000,0000,0000,,so it has a very strong notion of the Dialogue: 0,0:15:59.00,0:16:04.00,Default,,0000,0000,0000,,add operation on this kind of vector accepts this kind of thing. So if it's a Dialogue: 0,0:16:04.00,0:16:08.00,Default,,0000,0000,0000,,vector of strings, the add accepts strings. If it's a vector of [inaudible] add accepts integers, Dialogue: 0,0:16:08.00,0:16:11.00,Default,,0000,0000,0000,,and the crossing of that will cause compiler errors. Dialogue: 0,0:16:11.00,0:16:15.00,Default,,0000,0000,0000,,Similarly, when I'm trying to get something out of a vector, Dialogue: 0,0:16:15.00,0:16:19.00,Default,,0000,0000,0000,,that return value is typed for what you put in it. If you have a vector of Dialogue: 0,0:16:19.00,0:16:21.00,Default,,0000,0000,0000,,strings, then what you return is strings, not characters. Dialogue: 0,0:16:21.00,0:16:23.00,Default,,0000,0000,0000,,Or trying to do, kind of Dialogue: 0,0:16:23.00,0:16:26.00,Default,,0000,0000,0000,,take one vector; one vector is not equivalent to another if their base Dialogue: 0,0:16:26.00,0:16:29.00,Default,,0000,0000,0000,,types are not the same. So a vector of doubles Dialogue: 0,0:16:29.00,0:16:32.00,Default,,0000,0000,0000,,is not the same thing as a vector of integers. And so if I have a function Dialogue: 0,0:16:32.00,0:16:35.00,Default,,0000,0000,0000,,that expects one or tries to use on, it really [inaudible] a vector of in, a Dialogue: 0,0:16:35.00,0:16:38.00,Default,,0000,0000,0000,,vector of in is not the same thing as a vector of doubles, Dialogue: 0,0:16:38.00,0:16:41.00,Default,,0000,0000,0000,,and the complier will not let you kind of mix those things up. Dialogue: 0,0:16:41.00,0:16:43.00,Default,,0000,0000,0000,,So it provides pretty Dialogue: 0,0:16:43.00,0:16:44.00,Default,,0000,0000,0000,,good Dialogue: 0,0:16:44.00,0:16:47.00,Default,,0000,0000,0000,,error messages in these cases. It's a, here's Dialogue: 0,0:16:47.00,0:16:49.00,Default,,0000,0000,0000,,how you've gotten your types Dialogue: 0,0:16:49.00,0:16:53.00,Default,,0000,0000,0000,,confused. Dialogue: 0,0:16:53.00,0:16:56.00,Default,,0000,0000,0000,,[Inaudible] double bracket number and then - Dialogue: 0,0:16:56.00,0:16:59.00,Default,,0000,0000,0000,,Yeah, so if this said vector angle bracket [inaudible] then it would fine, then I would Dialogue: 0,0:16:59.00,0:17:02.00,Default,,0000,0000,0000,,just be making a copy of the nums into a new variable S that had a Dialogue: 0,0:17:02.00,0:17:04.00,Default,,0000,0000,0000,,complete same content that nums did. Dialogue: 0,0:17:04.00,0:17:07.00,Default,,0000,0000,0000,,So that would be totally fine. I can definitely do assignment from one vector to another if they Dialogue: 0,0:17:07.00,0:17:09.00,Default,,0000,0000,0000,,are of the same type, Dialogue: 0,0:17:09.00,0:17:12.00,Default,,0000,0000,0000,,but vector in is not the same thing as vector double which is not the same Dialogue: 0,0:17:12.00,0:17:14.00,Default,,0000,0000,0000,,thing as vector string, and so Dialogue: 0,0:17:14.00,0:17:16.00,Default,,0000,0000,0000,,it's - basically it means that - Dialogue: 0,0:17:16.00,0:17:19.00,Default,,0000,0000,0000,,what the template is, is a patter for which you can make a bunch of classes, and on demand Dialogue: 0,0:17:19.00,0:17:22.00,Default,,0000,0000,0000,,it makes new classes, the vector double, the vector in, the vector string. And each Dialogue: 0,0:17:22.00,0:17:26.00,Default,,0000,0000,0000,,of those is distinct from the other ones that have been created. Can I change the types of Dialogue: 0,0:17:26.00,0:17:27.00,Default,,0000,0000,0000,,nums in Dialogue: 0,0:17:27.00,0:17:28.00,Default,,0000,0000,0000,,the Dialogue: 0,0:17:28.00,0:17:30.00,Default,,0000,0000,0000,,expression and then - You cannot type [inaudible], Dialogue: 0,0:17:30.00,0:17:33.00,Default,,0000,0000,0000,,so it's not like I can type cast it down, they really are just different things and they're Dialogue: 0,0:17:33.00,0:17:36.00,Default,,0000,0000,0000,,stored differently, ints are a different size and doubles, so there's a bunch more things that Dialogue: 0,0:17:36.00,0:17:37.00,Default,,0000,0000,0000,,it Dialogue: 0,0:17:37.00,0:17:40.00,Default,,0000,0000,0000,,will just not do automatically in that case. If I really wanted to try to take a bunch of Dialogue: 0,0:17:40.00,0:17:44.00,Default,,0000,0000,0000,,integers and put them into a vector or doubles, I would end up Dialogue: 0,0:17:44.00,0:17:48.00,Default,,0000,0000,0000,,having to kind of do a one by one, take each int, convert it to a double and stick it into a new vector to get that effect. Dialogue: 0,0:17:48.00,0:17:50.00,Default,,0000,0000,0000,,Somebody in the back had something going on? Same question. Dialogue: 0,0:17:50.00,0:17:56.00,Default,,0000,0000,0000,,Same question, okay, so then we're good. Let me tell you a Dialogue: 0,0:17:56.00,0:17:57.00,Default,,0000,0000,0000,,little bit about grid, Dialogue: 0,0:17:57.00,0:18:00.00,Default,,0000,0000,0000,,which is just the extension of vector into two dimensions. Somebody asked Dialogue: 0,0:18:00.00,0:18:03.00,Default,,0000,0000,0000,,about this a minute ago, which is like, well can we do this? We can still [inaudible] vectors Dialogue: 0,0:18:03.00,0:18:04.00,Default,,0000,0000,0000,,of vectors Dialogue: 0,0:18:04.00,0:18:07.00,Default,,0000,0000,0000,,as one way of getting into two dimension, but often what you have is really a Dialogue: 0,0:18:07.00,0:18:11.00,Default,,0000,0000,0000,,rectangular region, where the number of rows and columns is fixed all the way Dialogue: 0,0:18:11.00,0:18:12.00,Default,,0000,0000,0000,,across, Dialogue: 0,0:18:12.00,0:18:15.00,Default,,0000,0000,0000,,in which case it might be convenient to have something like grid Dialogue: 0,0:18:15.00,0:18:18.00,Default,,0000,0000,0000,,that you just specify how big you want, how many rows, how many columns, and then Dialogue: 0,0:18:18.00,0:18:19.00,Default,,0000,0000,0000,,you get Dialogue: 0,0:18:19.00,0:18:20.00,Default,,0000,0000,0000,,a full Dialogue: 0,0:18:20.00,0:18:22.00,Default,,0000,0000,0000,,2D Dialogue: 0,0:18:22.00,0:18:24.00,Default,,0000,0000,0000,,matrix to hold those values. Dialogue: 0,0:18:24.00,0:18:27.00,Default,,0000,0000,0000,,So it is something that you set the dimensions of the constructors, you Dialogue: 0,0:18:27.00,0:18:28.00,Default,,0000,0000,0000,,make a new grid on int that Dialogue: 0,0:18:28.00,0:18:30.00,Default,,0000,0000,0000,,has ten rows and ten columns. Dialogue: 0,0:18:30.00,0:18:34.00,Default,,0000,0000,0000,,There actually is a number function resize that lets you later change the number of Dialogue: 0,0:18:34.00,0:18:37.00,Default,,0000,0000,0000,,rows and columns, Dialogue: 0,0:18:37.00,0:18:41.00,Default,,0000,0000,0000,,but typically you tend to actually - once you set it, it tends to stay that way. Dialogue: 0,0:18:41.00,0:18:47.00,Default,,0000,0000,0000,,You have access to each element by row and column, so you say I want the to getat Dialogue: 0,0:18:47.00,0:18:50.00,Default,,0000,0000,0000,,this row, this column, it will return you the value that's been stored there. Dialogue: 0,0:18:50.00,0:18:54.00,Default,,0000,0000,0000,,And I put it over here; it says elements have default [inaudible]. Dialogue: 0,0:18:54.00,0:18:57.00,Default,,0000,0000,0000,,So if you say I want a ten by ten grid of integers, Dialogue: 0,0:18:57.00,0:19:01.00,Default,,0000,0000,0000,,then it does create a full ten by ten grid of integers. If you ask it to retrieve the value at any of Dialogue: 0,0:19:01.00,0:19:03.00,Default,,0000,0000,0000,,those locations before you set them, they have Dialogue: 0,0:19:03.00,0:19:05.00,Default,,0000,0000,0000,,the same contents that Dialogue: 0,0:19:05.00,0:19:08.00,Default,,0000,0000,0000,,an integer declared of the stack would have, which is to say random. Dialogue: 0,0:19:08.00,0:19:10.00,Default,,0000,0000,0000,,So they're not zero, they're not negative one, they're not anything Dialogue: 0,0:19:10.00,0:19:13.00,Default,,0000,0000,0000,,special. They're whatever - kind of if you just have int setting around, what is its Dialogue: 0,0:19:13.00,0:19:15.00,Default,,0000,0000,0000,,default value? Dialogue: 0,0:19:15.00,0:19:18.00,Default,,0000,0000,0000,,For the primitive types that just means it's random. For some of the Dialogue: 0,0:19:18.00,0:19:21.00,Default,,0000,0000,0000,,more fancy types like string, it would mean they have the default value for Dialogue: 0,0:19:21.00,0:19:25.00,Default,,0000,0000,0000,,string, which is the empty string. So if I'm in a 2D grid of strings, then all the Dialogue: 0,0:19:25.00,0:19:29.00,Default,,0000,0000,0000,,strings would be empty until I explicitly did something to set and assign their Dialogue: 0,0:19:29.00,0:19:30.00,Default,,0000,0000,0000,,value. Dialogue: 0,0:19:30.00,0:19:33.00,Default,,0000,0000,0000,,So there's a getat setat pair that looks very much like the vector form that takes, in this Dialogue: 0,0:19:33.00,0:19:35.00,Default,,0000,0000,0000,,case, two arguments of the row and the column. Dialogue: 0,0:19:35.00,0:19:38.00,Default,,0000,0000,0000,,There's also an operator parens Dialogue: 0,0:19:38.00,0:19:43.00,Default,,0000,0000,0000,,that lets you say grid of parans, row column and separated by comma. I'll show that Dialogue: 0,0:19:43.00,0:19:44.00,Default,,0000,0000,0000,,syntax in just a second. Dialogue: 0,0:19:44.00,0:19:47.00,Default,,0000,0000,0000,,It does do full deep copying, the same way the vector does, which is if you Dialogue: 0,0:19:47.00,0:19:51.00,Default,,0000,0000,0000,,have a ten by ten grid which has a hundred members, when you pass or Dialogue: 0,0:19:51.00,0:19:56.00,Default,,0000,0000,0000,,return it by value, or you assign it, it has a full copy of that hundred member grid. Dialogue: 0,0:19:56.00,0:20:00.00,Default,,0000,0000,0000,,Lots of things sort of fit into the world of the grids Dialogue: 0,0:20:00.00,0:20:03.00,Default,,0000,0000,0000,,utility, any kind of game ward, you're doing battleship, you're doing a Sudoku, you're doing Dialogue: 0,0:20:03.00,0:20:06.00,Default,,0000,0000,0000,,a crossword puzzle, Dialogue: 0,0:20:06.00,0:20:08.00,Default,,0000,0000,0000,,designing a maze, Dialogue: 0,0:20:08.00,0:20:11.00,Default,,0000,0000,0000,,managing the data behind an image or any kind of mathematical matrix, or sort of table Dialogue: 0,0:20:11.00,0:20:16.00,Default,,0000,0000,0000,,tend to fit in the model for what a grid is good for. Dialogue: 0,0:20:16.00,0:20:19.00,Default,,0000,0000,0000,,This is the interface for grid, Dialogue: 0,0:20:19.00,0:20:21.00,Default,,0000,0000,0000,,so a template like vector was. Dialogue: 0,0:20:21.00,0:20:23.00,Default,,0000,0000,0000,,It has two different constructors; Dialogue: 0,0:20:23.00,0:20:29.00,Default,,0000,0000,0000,,one that is a little bit of an oddity. This one creates a zero row, zero Dialogue: 0,0:20:29.00,0:20:30.00,Default,,0000,0000,0000,,column Dialogue: 0,0:20:30.00,0:20:32.00,Default,,0000,0000,0000,,grids, totally empty, Dialogue: 0,0:20:32.00,0:20:34.00,Default,,0000,0000,0000,,which then you would later Dialogue: 0,0:20:34.00,0:20:38.00,Default,,0000,0000,0000,,most likely be making a resize call to change the number of rows and columns. That Dialogue: 0,0:20:38.00,0:20:41.00,Default,,0000,0000,0000,,might be useful in a situation where you need to create the grid before you kind of have information Dialogue: 0,0:20:41.00,0:20:43.00,Default,,0000,0000,0000,,about how to size it. Dialogue: 0,0:20:43.00,0:20:47.00,Default,,0000,0000,0000,,You can alternatively specify with a constructor the number of rows and Dialogue: 0,0:20:47.00,0:20:50.00,Default,,0000,0000,0000,,calls from the get go and have it set up, Dialogue: 0,0:20:50.00,0:20:52.00,Default,,0000,0000,0000,,and then you can later ask it for the number of rows and calls Dialogue: 0,0:20:52.00,0:20:55.00,Default,,0000,0000,0000,,and then you can getat and setat a Dialogue: 0,0:20:55.00,0:20:58.00,Default,,0000,0000,0000,,particular element within that grid Dialogue: 0,0:20:58.00,0:21:01.00,Default,,0000,0000,0000,,using those. There's also an operator - I'm not showing you the syntax in these for Dialogue: 0,0:21:01.00,0:21:04.00,Default,,0000,0000,0000,,the operator open parens, just because it's a little bit goopy, but I'll show you in the Dialogue: 0,0:21:04.00,0:21:07.00,Default,,0000,0000,0000,,client usage that Dialogue: 0,0:21:07.00,0:21:11.00,Default,,0000,0000,0000,,shows you how it works from that perspective. Dialogue: 0,0:21:11.00,0:21:14.00,Default,,0000,0000,0000,,So this is something let's say like maybe I'm playing a tic tac toe game and I Dialogue: 0,0:21:14.00,0:21:18.00,Default,,0000,0000,0000,,was gonna use the grid to hold the three by three board that has x's and Dialogue: 0,0:21:18.00,0:21:22.00,Default,,0000,0000,0000,,o's in it, and I want to start it off by having all of them have the space character. Dialogue: 0,0:21:22.00,0:21:24.00,Default,,0000,0000,0000,,So I'm going to using characters at each slot, Dialogue: 0,0:21:24.00,0:21:28.00,Default,,0000,0000,0000,,I create a board of three three, so this is the way you invoke a construction in Dialogue: 0,0:21:28.00,0:21:30.00,Default,,0000,0000,0000,,C++ that takes argument. Dialogue: 0,0:21:30.00,0:21:32.00,Default,,0000,0000,0000,,If you have no arguments, you don't have the parens or anything, you just have Dialogue: 0,0:21:32.00,0:21:37.00,Default,,0000,0000,0000,,the name, but if it does take one or more arguments, you'll open the paren and Dialogue: 0,0:21:37.00,0:21:40.00,Default,,0000,0000,0000,,list them out in order. In this case, the three and three being the number of rows and Dialogue: 0,0:21:40.00,0:21:41.00,Default,,0000,0000,0000,,columns. Dialogue: 0,0:21:41.00,0:21:42.00,Default,,0000,0000,0000,,And so at this point Dialogue: 0,0:21:42.00,0:21:44.00,Default,,0000,0000,0000,,I will have a Dialogue: 0,0:21:44.00,0:21:47.00,Default,,0000,0000,0000,,grid that has num rows three, num columns three, it has nine entries in it, and they're all Dialogue: 0,0:21:47.00,0:21:49.00,Default,,0000,0000,0000,,garbage. Dialogue: 0,0:21:49.00,0:21:51.00,Default,,0000,0000,0000,,Whatever characters that were left over in that place in memory is what actually Dialogue: 0,0:21:51.00,0:21:53.00,Default,,0000,0000,0000,,will be at each location. Dialogue: 0,0:21:53.00,0:21:56.00,Default,,0000,0000,0000,,And then I did a nested four loop over the rows and columns, Dialogue: 0,0:21:56.00,0:21:59.00,Default,,0000,0000,0000,,and here I am showing you the syntax for the Dialogue: 0,0:21:59.00,0:22:02.00,Default,,0000,0000,0000,,access to the row column in kind of a shorthand form Dialogue: 0,0:22:02.00,0:22:04.00,Default,,0000,0000,0000,,where I say board of Dialogue: 0,0:22:04.00,0:22:07.00,Default,,0000,0000,0000,,and then parens bro , column = space. Dialogue: 0,0:22:07.00,0:22:11.00,Default,,0000,0000,0000,,Equivalently that could have been the member function setat board. Setat Dialogue: 0,0:22:11.00,0:22:15.00,Default,,0000,0000,0000,,row column space to accomplish the same result. Dialogue: 0,0:22:15.00,0:22:17.00,Default,,0000,0000,0000,,So this is still like vector sub I, Dialogue: 0,0:22:17.00,0:22:20.00,Default,,0000,0000,0000,,it can be used to read or to write. Dialogue: 0,0:22:20.00,0:22:23.00,Default,,0000,0000,0000,,It does bounced checking to make sure that row and column are greater than or Dialogue: 0,0:22:23.00,0:22:26.00,Default,,0000,0000,0000,,equal to zero and less than the Dialogue: 0,0:22:26.00,0:22:28.00,Default,,0000,0000,0000,,number of rows or number of columns respectively. Dialogue: 0,0:22:28.00,0:22:32.00,Default,,0000,0000,0000,,So it raises an error if you ever get outside the bounds of the Dialogue: 0,0:22:32.00,0:22:35.00,Default,,0000,0000,0000,,grid. And then this return at the end just returns that full grid. Dialogue: 0,0:22:35.00,0:22:37.00,Default,,0000,0000,0000,,In this case, the nine Dialogue: 0,0:22:37.00,0:22:39.00,Default,,0000,0000,0000,,by entry, three by three Dialogue: 0,0:22:39.00,0:22:48.00,Default,,0000,0000,0000,,back to someone else who's gonna store it and so something with it. Dialogue: 0,0:22:48.00,0:22:50.00,Default,,0000,0000,0000,, Dialogue: 0,0:22:50.00,0:22:51.00,Default,,0000,0000,0000,,[Inaudible] Dialogue: 0,0:22:51.00,0:22:55.00,Default,,0000,0000,0000,, Dialogue: 0,0:22:55.00,0:22:58.00,Default,,0000,0000,0000,, Dialogue: 0,0:22:58.00,0:23:01.00,Default,,0000,0000,0000,,There is actual one distinction between a vector and a vector of a grid that's kinda interesting, Dialogue: 0,0:23:01.00,0:23:04.00,Default,,0000,0000,0000,,the grid is rectangular, it forces there to be Dialogue: 0,0:23:04.00,0:23:07.00,Default,,0000,0000,0000,,exactly the same number of rows and column kind of for the whole thing. That Dialogue: 0,0:23:07.00,0:23:09.00,Default,,0000,0000,0000,,a vector - if you created a vector of vector, Dialogue: 0,0:23:09.00,0:23:13.00,Default,,0000,0000,0000,,you could individually size each row as needed. This could have ten, this Dialogue: 0,0:23:13.00,0:23:16.00,Default,,0000,0000,0000,,could have three, and so like a vector vector might be interesting if you Dialogue: 0,0:23:16.00,0:23:20.00,Default,,0000,0000,0000,,had something - well they call that kind of the ragged right behavior, where they Dialogue: 0,0:23:20.00,0:23:23.00,Default,,0000,0000,0000,,don't all line up over here. But if you really have something that's tabular, Dialogue: 0,0:23:23.00,0:23:26.00,Default,,0000,0000,0000,,that there is a rectangular shape to it, the grid is going to Dialogue: 0,0:23:26.00,0:23:28.00,Default,,0000,0000,0000,,be a little bit easier to get it up and running, Dialogue: 0,0:23:28.00,0:23:30.00,Default,,0000,0000,0000,,but the vector vector's certainly would work, but Dialogue: 0,0:23:30.00,0:23:32.00,Default,,0000,0000,0000,,if you were doing Dialogue: 0,0:23:32.00,0:23:34.00,Default,,0000,0000,0000,,an array of Dialogue: 0,0:23:34.00,0:23:38.00,Default,,0000,0000,0000,,class lists where some classes have ten and some classes have four hundred, but Dialogue: 0,0:23:38.00,0:23:41.00,Default,,0000,0000,0000,,if you tried to do that with a grid you'd have to size the whole thing to Dialogue: 0,0:23:41.00,0:23:48.00,Default,,0000,0000,0000,,have a much larger row dimension than was needed in most cases. Dialogue: 0,0:23:48.00,0:23:50.00,Default,,0000,0000,0000,,So there's no square bracket operator? Dialogue: 0,0:23:50.00,0:23:53.00,Default,,0000,0000,0000,,There is not, and there is kinda an obscure reason for that, and if you are curious, Dialogue: 0,0:23:53.00,0:23:56.00,Default,,0000,0000,0000,,you can come to the cafe afterwards, and I'll tell you why it is, Dialogue: 0,0:23:56.00,0:23:58.00,Default,,0000,0000,0000,,but Dialogue: 0,0:23:58.00,0:24:01.00,Default,,0000,0000,0000,,some of the syntax you may have seen in the past has two square brackets, you say sub Dialogue: 0,0:24:01.00,0:24:03.00,Default,,0000,0000,0000,,row, sub column, Dialogue: 0,0:24:03.00,0:24:07.00,Default,,0000,0000,0000,,and to have that work on a class in C++ Dialogue: 0,0:24:07.00,0:24:08.00,Default,,0000,0000,0000,,doesn't - it's not as clean. So it Dialogue: 0,0:24:08.00,0:24:11.00,Default,,0000,0000,0000,,turns out we use the parens, because it turns out as a cleaner was of Dialogue: 0,0:24:11.00,0:24:14.00,Default,,0000,0000,0000,,accomplishing the thing we wanted, which was a short hand access into Dialogue: 0,0:24:14.00,0:24:15.00,Default,,0000,0000,0000,,there. Dialogue: 0,0:24:15.00,0:24:21.00,Default,,0000,0000,0000,,So it doesn't actually use the square bracket operator. Question here? Dialogue: 0,0:24:21.00,0:24:22.00,Default,,0000,0000,0000,,[Inaudible] when Dialogue: 0,0:24:22.00,0:24:25.00,Default,,0000,0000,0000,,you Dialogue: 0,0:24:25.00,0:24:27.00,Default,,0000,0000,0000,,created support three by three and you Dialogue: 0,0:24:27.00,0:24:32.00,Default,,0000,0000,0000,,said it was forced to be a square, so why would you ever have to Dialogue: 0,0:24:32.00,0:24:35.00,Default,,0000,0000,0000,,enter the second? It's forced to be rectangular; it's not forced to be square. It could be three by ten, so I could Dialogue: 0,0:24:35.00,0:24:38.00,Default,,0000,0000,0000,,have three rows by ten columns, but Dialogue: 0,0:24:38.00,0:24:40.00,Default,,0000,0000,0000,,it does mean that every row has the same number of columns, but the row Dialogue: 0,0:24:40.00,0:24:44.00,Default,,0000,0000,0000,,and number of rows and columns doesn't have to be equal, I'm sorry. [Inaudible] if I made squares, the Dialogue: 0,0:24:44.00,0:24:52.00,Default,,0000,0000,0000,,wrong word really rectangular is it. So Dialogue: 0,0:24:52.00,0:24:54.00,Default,,0000,0000,0000,,then I'm gonna very quickly tell you these last two and they're actually even easier to Dialogue: 0,0:24:54.00,0:24:57.00,Default,,0000,0000,0000,,get your head around, because they're actually just simplified versions of Dialogue: 0,0:24:57.00,0:25:00.00,Default,,0000,0000,0000,,something you already know, which is to take the vector Dialogue: 0,0:25:00.00,0:25:02.00,Default,,0000,0000,0000,,and actually limit what you can do with it Dialogue: 0,0:25:02.00,0:25:05.00,Default,,0000,0000,0000,,to produce the stack in the queue class. Dialogue: 0,0:25:05.00,0:25:06.00,Default,,0000,0000,0000,,It Dialogue: 0,0:25:06.00,0:25:09.00,Default,,0000,0000,0000,,seems like kind of a strange thing to do if you already had a class that did something, why Dialogue: 0,0:25:09.00,0:25:12.00,Default,,0000,0000,0000,,would you want to dumb it down, but there actually are some good reasons that I'll hopefully Dialogue: 0,0:25:12.00,0:25:15.00,Default,,0000,0000,0000,,convince you of that why we have a stack and a queue. Dialogue: 0,0:25:15.00,0:25:17.00,Default,,0000,0000,0000,,So what a stack is about is modeling Dialogue: 0,0:25:17.00,0:25:21.00,Default,,0000,0000,0000,,the real world concept of a stack. If you have a stack of papers or a stack Dialogue: 0,0:25:21.00,0:25:22.00,Default,,0000,0000,0000,,of plates Dialogue: 0,0:25:22.00,0:25:24.00,Default,,0000,0000,0000,,you come and you put new things on the top of that Dialogue: 0,0:25:24.00,0:25:28.00,Default,,0000,0000,0000,,and then when it's time to take one off you take the top one. All right, so you don't dig Dialogue: 0,0:25:28.00,0:25:30.00,Default,,0000,0000,0000,,through the bottom of the stack, you don't reach over to the bottom. So if you Dialogue: 0,0:25:30.00,0:25:32.00,Default,,0000,0000,0000,,go up to get Dialogue: 0,0:25:32.00,0:25:33.00,Default,,0000,0000,0000,, Dialogue: 0,0:25:33.00,0:25:36.00,Default,,0000,0000,0000,,a plate in the cafeteria you just take the one that's on the top. When they put new Dialogue: 0,0:25:36.00,0:25:38.00,Default,,0000,0000,0000,,clean ones they stick them on the top. Dialogue: 0,0:25:38.00,0:25:40.00,Default,,0000,0000,0000,,So this Dialogue: 0,0:25:40.00,0:25:45.00,Default,,0000,0000,0000,,could be - you could take a vector and model exactly that behavior where all the Dialogue: 0,0:25:45.00,0:25:49.00,Default,,0000,0000,0000,,edits to that - all the additions and remove operations have to happen on the Dialogue: 0,0:25:49.00,0:25:50.00,Default,,0000,0000,0000,,top or one end of the vector, Dialogue: 0,0:25:50.00,0:25:53.00,Default,,0000,0000,0000,,and that's basically what a stack does. Is Dialogue: 0,0:25:53.00,0:25:56.00,Default,,0000,0000,0000,,it provides something that looks like a vector Dialogue: 0,0:25:56.00,0:25:59.00,Default,,0000,0000,0000,,but that only allows you access to the top end of the stack. Dialogue: 0,0:25:59.00,0:26:01.00,Default,,0000,0000,0000,,It has the operation push Dialogue: 0,0:26:01.00,0:26:04.00,Default,,0000,0000,0000,,which is to say put a new thing on the top of the stack. Dialogue: 0,0:26:04.00,0:26:08.00,Default,,0000,0000,0000,,It has the operation pop, which is remove the top most element on the stack, Dialogue: 0,0:26:08.00,0:26:11.00,Default,,0000,0000,0000,,and there's actually a peak operation that looks at what's on the top without Dialogue: 0,0:26:11.00,0:26:12.00,Default,,0000,0000,0000,,removing it. Dialogue: 0,0:26:12.00,0:26:15.00,Default,,0000,0000,0000,,There is no access to anything further down. Dialogue: 0,0:26:15.00,0:26:18.00,Default,,0000,0000,0000,,If you want to see at the bottom or what's in the middle, the stack Dialogue: 0,0:26:18.00,0:26:22.00,Default,,0000,0000,0000,,doesn't let you do it. It gives a kind of a little window to look at this Dialogue: 0,0:26:22.00,0:26:23.00,Default,,0000,0000,0000,,information Dialogue: 0,0:26:23.00,0:26:25.00,Default,,0000,0000,0000,,that's restricted. Dialogue: 0,0:26:25.00,0:26:28.00,Default,,0000,0000,0000,,That seems a little bit strange, Dialogue: 0,0:26:28.00,0:26:31.00,Default,,0000,0000,0000,,why is it when you want - like sometimes you could do that with a Dialogue: 0,0:26:31.00,0:26:34.00,Default,,0000,0000,0000,,vector by always adding to the end and always forcing yourself to remove from the Dialogue: 0,0:26:34.00,0:26:34.00,Default,,0000,0000,0000,,end, Dialogue: 0,0:26:34.00,0:26:37.00,Default,,0000,0000,0000,,but then just ignoring the fact that you could dig through the other parts of the vector. And Dialogue: 0,0:26:37.00,0:26:38.00,Default,,0000,0000,0000,, Dialogue: 0,0:26:38.00,0:26:41.00,Default,,0000,0000,0000,,there are a few really good reasons to have the stack around, because there are certain Dialogue: 0,0:26:41.00,0:26:44.00,Default,,0000,0000,0000,,things that really are stack based operations. A good example of is like if Dialogue: 0,0:26:44.00,0:26:46.00,Default,,0000,0000,0000,,you are Dialogue: 0,0:26:46.00,0:26:48.00,Default,,0000,0000,0000,,doing the web browser history Dialogue: 0,0:26:48.00,0:26:49.00,Default,,0000,0000,0000,,when you can walk forward, Dialogue: 0,0:26:49.00,0:26:51.00,Default,,0000,0000,0000,,but then you can back up. Dialogue: 0,0:26:51.00,0:26:54.00,Default,,0000,0000,0000,,You don't need to be able to jump all the way back to the end, you're just going back Dialogue: 0,0:26:54.00,0:26:57.00,Default,,0000,0000,0000,,in time. Or if you undoing the actions in a word processors, you type some things Dialogue: 0,0:26:57.00,0:26:58.00,Default,,0000,0000,0000,,and you undo it, Dialogue: 0,0:26:58.00,0:27:02.00,Default,,0000,0000,0000,,that you always undo the last most operations before you undo things before Dialogue: 0,0:27:02.00,0:27:05.00,Default,,0000,0000,0000,,that. And having it be a vector where you can kind of did through it means there's a chance Dialogue: 0,0:27:05.00,0:27:08.00,Default,,0000,0000,0000,,you could make a mistake. You could accidently pull from the wrong end or do Dialogue: 0,0:27:08.00,0:27:08.00,Default,,0000,0000,0000,,something Dialogue: 0,0:27:08.00,0:27:11.00,Default,,0000,0000,0000,,that you didn't intend. By having the stack it kinda forces you to use it the way Dialogue: 0,0:27:11.00,0:27:15.00,Default,,0000,0000,0000,,you said you planned on, which is I'm only going to stack on the end, I'm going to Dialogue: 0,0:27:15.00,0:27:17.00,Default,,0000,0000,0000,,remove from the end. Dialogue: 0,0:27:17.00,0:27:18.00,Default,,0000,0000,0000,,So it lets you model Dialogue: 0,0:27:18.00,0:27:22.00,Default,,0000,0000,0000,,this particular kind of limited access vector Dialogue: 0,0:27:22.00,0:27:23.00,Default,,0000,0000,0000,,in a way that Dialogue: 0,0:27:23.00,0:27:26.00,Default,,0000,0000,0000,,prevents you from making mistakes, and also very clearly indicates to someone reading Dialogue: 0,0:27:26.00,0:27:28.00,Default,,0000,0000,0000,,your code what you were doing. Dialogue: 0,0:27:28.00,0:27:31.00,Default,,0000,0000,0000,,So for example, stacks are very well known to all computer scientists. It's one of the Dialogue: 0,0:27:31.00,0:27:33.00,Default,,0000,0000,0000,,classic data structures. Dialogue: 0,0:27:33.00,0:27:36.00,Default,,0000,0000,0000,,We think of, for example, the function calls as a stack. Dialogue: 0,0:27:36.00,0:27:40.00,Default,,0000,0000,0000,,You call main which calls binky which calls winky, well winky comes back and Dialogue: 0,0:27:40.00,0:27:41.00,Default,,0000,0000,0000,,finishes, we get back to Dialogue: 0,0:27:41.00,0:27:45.00,Default,,0000,0000,0000,,the binky call, we go back to main, then it always goes in this last in, first out, Dialogue: 0,0:27:45.00,0:27:46.00,Default,,0000,0000,0000,,that Dialogue: 0,0:27:46.00,0:27:47.00,Default,,0000,0000,0000,,the last thing we started Dialogue: 0,0:27:47.00,0:27:51.00,Default,,0000,0000,0000,,is the first one to undo and go backwards to as we work our way back Dialogue: 0,0:27:51.00,0:27:53.00,Default,,0000,0000,0000,,down to the bottom of the stack. Dialogue: 0,0:27:53.00,0:27:56.00,Default,,0000,0000,0000,,And so computer scientists have a very strong notion of what a stack is. You declare Dialogue: 0,0:27:56.00,0:27:59.00,Default,,0000,0000,0000,,something as a stack and that immediately says to them, I see how you're Dialogue: 0,0:27:59.00,0:28:03.00,Default,,0000,0000,0000,,using this. You plan on adding to the end and removing from that same end. Dialogue: 0,0:28:03.00,0:28:06.00,Default,,0000,0000,0000,,So you can do things like reversal sequence very easily. Dialogue: 0,0:28:06.00,0:28:09.00,Default,,0000,0000,0000,,Put it all on the stack, pop it all off, it came back in the opposite order you put it on. Dialogue: 0,0:28:09.00,0:28:13.00,Default,,0000,0000,0000,,You put ABC on you'll get CBA off. If I put Dialogue: 0,0:28:13.00,0:28:16.00,Default,,0000,0000,0000,,5 3 12 on, I'll get 12 3 5 off. So anytime I needed to do a Dialogue: 0,0:28:16.00,0:28:19.00,Default,,0000,0000,0000,,reversing thing, a stack is a great place to just temporarily throw it and then Dialogue: 0,0:28:19.00,0:28:21.00,Default,,0000,0000,0000,,pull it back out. Dialogue: 0,0:28:21.00,0:28:25.00,Default,,0000,0000,0000,,Managing any sequence of [inaudible] action, the moves and again, the keystrokes in your Dialogue: 0,0:28:25.00,0:28:27.00,Default,,0000,0000,0000,,edits you've made in the Dialogue: 0,0:28:27.00,0:28:30.00,Default,,0000,0000,0000,,word processor, tracking the history when your web browsing of where Dialogue: 0,0:28:30.00,0:28:32.00,Default,,0000,0000,0000,,you've been and where you want to back up to Dialogue: 0,0:28:32.00,0:28:36.00,Default,,0000,0000,0000,,are all stack based activities. Dialogue: 0,0:28:36.00,0:28:39.00,Default,,0000,0000,0000,,So if you look at stack, it actually has an even simpler interface than vector for Dialogue: 0,0:28:39.00,0:28:41.00,Default,,0000,0000,0000,,that matter. Dialogue: 0,0:28:41.00,0:28:45.00,Default,,0000,0000,0000,,It has the corresponding size n is empty, so you'll see a lot of repetition Dialogue: 0,0:28:45.00,0:28:49.00,Default,,0000,0000,0000,,throughout the interface where we could reuse names that you already know Dialogue: 0,0:28:49.00,0:28:52.00,Default,,0000,0000,0000,,and have meaning for, we just reproduce them Dialogue: 0,0:28:52.00,0:28:55.00,Default,,0000,0000,0000,,from class to class, so there's a size that tells you how many things are on the Dialogue: 0,0:28:55.00,0:28:58.00,Default,,0000,0000,0000,,stack, and is empty, that tells you whether the size is zero, Dialogue: 0,0:28:58.00,0:29:01.00,Default,,0000,0000,0000,,and then the push and pop operations that add something Dialogue: 0,0:29:01.00,0:29:02.00,Default,,0000,0000,0000,,and remove it. Dialogue: 0,0:29:02.00,0:29:05.00,Default,,0000,0000,0000,,And they don't allow you to specify where it goes; it is assumed it's going on the top of the Dialogue: 0,0:29:05.00,0:29:08.00,Default,,0000,0000,0000,,stack, and then that peak that lets you look at what's on the top without Dialogue: 0,0:29:08.00,0:29:15.00,Default,,0000,0000,0000,,removing it. Dialogue: 0,0:29:15.00,0:29:18.00,Default,,0000,0000,0000,,Yeah? So if you Dialogue: 0,0:29:18.00,0:29:19.00,Default,,0000,0000,0000,,[inaudible] that had Dialogue: 0,0:29:19.00,0:29:22.00,Default,,0000,0000,0000,,nothing in it, would you just get - You get an error. So these guys are very bullet proof. One of the things we tried to do in Dialogue: 0,0:29:22.00,0:29:24.00,Default,,0000,0000,0000,,designing our interface was give you a simple Dialogue: 0,0:29:24.00,0:29:27.00,Default,,0000,0000,0000,,model you can follow, but also if you step out of the boundaries of what we Dialogue: 0,0:29:27.00,0:29:28.00,Default,,0000,0000,0000,,know to be acceptable, Dialogue: 0,0:29:28.00,0:29:33.00,Default,,0000,0000,0000,,we really stop hard and fast. So if you try to pop from an empty stacker, peak at an Dialogue: 0,0:29:33.00,0:29:35.00,Default,,0000,0000,0000,,empty stack, it will print and error and halt your program. It Dialogue: 0,0:29:35.00,0:29:42.00,Default,,0000,0000,0000,,won't make it up, it won't guess, it won't - [Inaudible] Dialogue: 0,0:29:42.00,0:29:46.00,Default,,0000,0000,0000,,Well, so the stack knows its size and it [inaudible] is empty, Dialogue: 0,0:29:46.00,0:29:50.00,Default,,0000,0000,0000,,so when you're unloading a stack you'll typically be in a loop like, well the Dialogue: 0,0:29:50.00,0:29:52.00,Default,,0000,0000,0000,,stacks not empty, pop. Dialogue: 0,0:29:52.00,0:29:54.00,Default,,0000,0000,0000,,So there's definitely ways you can check ahead of time to know whether there is something Dialogue: 0,0:29:54.00,0:29:56.00,Default,,0000,0000,0000,,there or not, and Dialogue: 0,0:29:56.00,0:29:58.00,Default,,0000,0000,0000,,it's all managed as part of the stack. Dialogue: 0,0:29:58.00,0:30:01.00,Default,,0000,0000,0000,,But if you blow it and you try to reach into the stack that's empty, Dialogue: 0,0:30:01.00,0:30:02.00,Default,,0000,0000,0000,, Dialogue: 0,0:30:02.00,0:30:03.00,Default,,0000,0000,0000,,it won't let you get away with it. Dialogue: 0,0:30:03.00,0:30:07.00,Default,,0000,0000,0000,,And that's really what you want. That means that they run a little slower Dialogue: 0,0:30:07.00,0:30:10.00,Default,,0000,0000,0000,,than the counterparts in the standard library, but Dialogue: 0,0:30:10.00,0:30:13.00,Default,,0000,0000,0000,,they never let you make that kind of mistake without Dialogue: 0,0:30:13.00,0:30:16.00,Default,,0000,0000,0000,,alerting you to it, where as the standard library will actually respond a little Dialogue: 0,0:30:16.00,0:30:19.00,Default,,0000,0000,0000,,bit less graciously. It would be more likely to just make it up. Dialogue: 0,0:30:19.00,0:30:20.00,Default,,0000,0000,0000,,You tell it to pop Dialogue: 0,0:30:20.00,0:30:22.00,Default,,0000,0000,0000,,and the Dialogue: 0,0:30:22.00,0:30:22.00,Default,,0000,0000,0000,,contract is, yeah, Dialogue: 0,0:30:22.00,0:30:27.00,Default,,0000,0000,0000,,I'll return you something if I feel like it and it may be what - it may Dialogue: 0,0:30:27.00,0:30:29.00,Default,,0000,0000,0000,,be something that actually misleads you into thinking there was some valid contents Dialogue: 0,0:30:29.00,0:30:33.00,Default,,0000,0000,0000,,on the stack and causes the error to kinda propagate further before you realize Dialogue: 0,0:30:33.00,0:30:35.00,Default,,0000,0000,0000,,how far you've Dialogue: 0,0:30:35.00,0:30:39.00,Default,,0000,0000,0000,,come from what its real genesis was. So one of the nice things about reporting the error Dialogue: 0,0:30:39.00,0:30:40.00,Default,,0000,0000,0000,,at the first Dialogue: 0,0:30:40.00,0:30:45.00,Default,,0000,0000,0000,,glance is it gives you the best information about how to fix it. Dialogue: 0,0:30:45.00,0:30:48.00,Default,,0000,0000,0000,,So here's something that just uses the stack to invert Dialogue: 0,0:30:48.00,0:30:48.00,Default,,0000,0000,0000,, Dialogue: 0,0:30:48.00,0:30:50.00,Default,,0000,0000,0000,,a string in this case, right, Dialogue: 0,0:30:50.00,0:30:53.00,Default,,0000,0000,0000,,something a user typed in. So I Dialogue: 0,0:30:53.00,0:30:56.00,Default,,0000,0000,0000,,prompted for them to enter something for me, I get that line Dialogue: 0,0:30:56.00,0:30:58.00,Default,,0000,0000,0000,,and then I create a stack of characters. Dialogue: 0,0:30:58.00,0:31:02.00,Default,,0000,0000,0000,,So the stack in this case is being created empty and then I take each Dialogue: 0,0:31:02.00,0:31:03.00,Default,,0000,0000,0000,,character one by Dialogue: 0,0:31:03.00,0:31:07.00,Default,,0000,0000,0000,,one from the first to the last and push it onto the stack, and so if they Dialogue: 0,0:31:07.00,0:31:07.00,Default,,0000,0000,0000,,answered Dialogue: 0,0:31:07.00,0:31:10.00,Default,,0000,0000,0000,,Hello, then we would put H-E-L-L-O on the stack. Dialogue: 0,0:31:10.00,0:31:12.00,Default,,0000,0000,0000,,And then print it backwards, Dialogue: 0,0:31:12.00,0:31:16.00,Default,,0000,0000,0000,,well the stack is not empty I pop and print it back out, so I'll get Dialogue: 0,0:31:16.00,0:31:16.00,Default,,0000,0000,0000,, Dialogue: 0,0:31:16.00,0:31:18.00,Default,,0000,0000,0000,,O-L-L-E-H back out of that Dialogue: 0,0:31:18.00,0:31:20.00,Default,,0000,0000,0000,,and the loop will exit when it has emptied the Dialogue: 0,0:31:20.00,0:31:26.00,Default,,0000,0000,0000,,stack completely. Dialogue: 0,0:31:26.00,0:31:30.00,Default,,0000,0000,0000,, Dialogue: 0,0:31:30.00,0:31:32.00,Default,,0000,0000,0000,,Stack [inaudible] just is Dialogue: 0,0:31:32.00,0:31:34.00,Default,,0000,0000,0000,,a simpler form of that. The Dialogue: 0,0:31:34.00,0:31:37.00,Default,,0000,0000,0000,,queue is just the cousin of the stack. Dialogue: 0,0:31:37.00,0:31:39.00,Default,,0000,0000,0000,,Same sort of idea is that Dialogue: 0,0:31:39.00,0:31:42.00,Default,,0000,0000,0000,,there's certain usage patterns for a vector Dialogue: 0,0:31:42.00,0:31:47.00,Default,,0000,0000,0000,,that form kind of their own class that's worth kinda giving a Dialogue: 0,0:31:47.00,0:31:50.00,Default,,0000,0000,0000,,name to and building an abstraction around, the queue. Dialogue: 0,0:31:50.00,0:31:54.00,Default,,0000,0000,0000,,The queue instead of being last in first out is first in first out. So the first Dialogue: 0,0:31:54.00,0:31:56.00,Default,,0000,0000,0000,,thing you add into the queue Dialogue: 0,0:31:56.00,0:32:00.00,Default,,0000,0000,0000,,is going to be the first one you remove. So you add at the front - you Dialogue: 0,0:32:00.00,0:32:03.00,Default,,0000,0000,0000,,add at the back and you remove from the front, it models a waiting line. Dialogue: 0,0:32:03.00,0:32:07.00,Default,,0000,0000,0000,,So if you think of lets say the head of the queue and tail, Dialogue: 0,0:32:07.00,0:32:11.00,Default,,0000,0000,0000,,or the front or the back of the line, that A was placed in the queue first, Dialogue: 0,0:32:11.00,0:32:13.00,Default,,0000,0000,0000,,that operation's called n queue; Dialogue: 0,0:32:13.00,0:32:16.00,Default,,0000,0000,0000,,n queue A, n queue B, n queue C, n queue D, Dialogue: 0,0:32:16.00,0:32:21.00,Default,,0000,0000,0000,,and then when you d queue, which is the remove operation on a queue, it will pull the Dialogue: 0,0:32:21.00,0:32:22.00,Default,,0000,0000,0000,,oldest thing in the queue, the one that was there Dialogue: 0,0:32:22.00,0:32:24.00,Default,,0000,0000,0000,,first who's been waiting the longest. Dialogue: 0,0:32:24.00,0:32:30.00,Default,,0000,0000,0000,,So removing the A and then next d queue will give you that B and so on. So Dialogue: 0,0:32:30.00,0:32:33.00,Default,,0000,0000,0000,,it does what you think of as your classic waiting line. Dialogue: 0,0:32:33.00,0:32:35.00,Default,,0000,0000,0000,,You're at the bank waiting for a teller. Dialogue: 0,0:32:35.00,0:32:38.00,Default,,0000,0000,0000,,The keystrokes that you're typing are being likely stored in something Dialogue: 0,0:32:38.00,0:32:42.00,Default,,0000,0000,0000,,that's queue like, setting up the jobs for a printer so that Dialogue: 0,0:32:42.00,0:32:45.00,Default,,0000,0000,0000,,there's fair access to it, where first come, first served, Dialogue: 0,0:32:45.00,0:32:48.00,Default,,0000,0000,0000,,and there's a couple kind of search [inaudible] that actually tend to use queue Dialogue: 0,0:32:48.00,0:32:51.00,Default,,0000,0000,0000,,as the way to kind of keep track of where you are. Dialogue: 0,0:32:51.00,0:32:54.00,Default,,0000,0000,0000,,So again, I could use vector for this, Dialogue: 0,0:32:54.00,0:32:58.00,Default,,0000,0000,0000,,just making a deal with myself that I'll add at one end and I'll always remove the zero with Dialogue: 0,0:32:58.00,0:32:59.00,Default,,0000,0000,0000,,element, Dialogue: 0,0:32:59.00,0:33:00.00,Default,,0000,0000,0000,,but again, Dialogue: 0,0:33:00.00,0:33:03.00,Default,,0000,0000,0000,,the effect is that if somebody sees me using a vector, Dialogue: 0,0:33:03.00,0:33:06.00,Default,,0000,0000,0000,,that they'd have to look at the code more closely Dialogue: 0,0:33:06.00,0:33:10.00,Default,,0000,0000,0000,,to see all my access to it, when I add, and when I remove to verify that I was Dialogue: 0,0:33:10.00,0:33:12.00,Default,,0000,0000,0000,,using it in a queue like manner, that I always Dialogue: 0,0:33:12.00,0:33:14.00,Default,,0000,0000,0000,,add it to the back an remove from the front. Dialogue: 0,0:33:14.00,0:33:16.00,Default,,0000,0000,0000,,If I say it's a queue, Dialogue: 0,0:33:16.00,0:33:20.00,Default,,0000,0000,0000,,they know that there is no other access than the n queue d queue Dialogue: 0,0:33:20.00,0:33:23.00,Default,,0000,0000,0000,,that operates using this FIFO, first in, first Dialogue: 0,0:33:23.00,0:33:25.00,Default,,0000,0000,0000,,out control, Dialogue: 0,0:33:25.00,0:33:29.00,Default,,0000,0000,0000,,so they don't have to look any closer at my usage of it to know what I'm up to. Dialogue: 0,0:33:29.00,0:33:32.00,Default,,0000,0000,0000,,The other thing that both stack and queue have which Dialogue: 0,0:33:32.00,0:33:34.00,Default,,0000,0000,0000,,won't be apparent now, but will Dialogue: 0,0:33:34.00,0:33:36.00,Default,,0000,0000,0000,,when we get a little further in the course, Dialogue: 0,0:33:36.00,0:33:37.00,Default,,0000,0000,0000,,is that by Dialogue: 0,0:33:37.00,0:33:40.00,Default,,0000,0000,0000,,defining the queue extraction to have kind of less features, Dialogue: 0,0:33:40.00,0:33:43.00,Default,,0000,0000,0000,,to be what seems to be less powerful Dialogue: 0,0:33:43.00,0:33:47.00,Default,,0000,0000,0000,,and have sort of a smaller set of things it has to support, Dialogue: 0,0:33:47.00,0:33:50.00,Default,,0000,0000,0000,,also has some certain advantages from the implementation side. That Dialogue: 0,0:33:50.00,0:33:53.00,Default,,0000,0000,0000,,if I know somebody's always going to be sticking things on this end and that end, but Dialogue: 0,0:33:53.00,0:33:55.00,Default,,0000,0000,0000,,not mucking around in the middle, Dialogue: 0,0:33:55.00,0:33:58.00,Default,,0000,0000,0000,,then I can make certain implementation decisions that support the necessary Dialogue: 0,0:33:58.00,0:34:00.00,Default,,0000,0000,0000,,operations very efficiently, Dialogue: 0,0:34:00.00,0:34:03.00,Default,,0000,0000,0000,,but don't actually do these things well because they don't need to, Dialogue: 0,0:34:03.00,0:34:06.00,Default,,0000,0000,0000,,in a way that vector can't make those trade offs. Vector doesn't know for sure Dialogue: 0,0:34:06.00,0:34:09.00,Default,,0000,0000,0000,,whether people will be mucking around with the middle or the ends or Dialogue: 0,0:34:09.00,0:34:10.00,Default,,0000,0000,0000,,the front or the back, Dialogue: 0,0:34:10.00,0:34:13.00,Default,,0000,0000,0000,,and so it has to kinda support everything equally well, that stack and Dialogue: 0,0:34:13.00,0:34:17.00,Default,,0000,0000,0000,,queue has a really specific usage pattern that then we can Dialogue: 0,0:34:17.00,0:34:20.00,Default,,0000,0000,0000,,use to guide our implementation decisions to make sure it runs Dialogue: 0,0:34:20.00,0:34:23.00,Default,,0000,0000,0000,,efficiently for that usage pattern. Dialogue: 0,0:34:23.00,0:34:27.00,Default,,0000,0000,0000,,So the same constructor or destructor in size is empty, that kind of Dialogue: 0,0:34:27.00,0:34:28.00,Default,,0000,0000,0000,,all our linear collections to, Dialogue: 0,0:34:28.00,0:34:32.00,Default,,0000,0000,0000,,and then it's operations which look just like push and pop but with a slight Dialogue: 0,0:34:32.00,0:34:36.00,Default,,0000,0000,0000,,change in verb here, n queue and d queue, Dialogue: 0,0:34:36.00,0:34:39.00,Default,,0000,0000,0000,,that add to the back, remove from the front, Dialogue: 0,0:34:39.00,0:34:40.00,Default,,0000,0000,0000,,and then peak Dialogue: 0,0:34:40.00,0:34:43.00,Default,,0000,0000,0000,,is the corresponding look at what's in the front. Like what would be d queued, Dialogue: 0,0:34:43.00,0:34:51.00,Default,,0000,0000,0000,,but without removing it from the queue, so just see who's at the head of the line. Dialogue: 0,0:34:51.00,0:34:54.00,Default,,0000,0000,0000,,And so a little piece of code I stole from the handout Dialogue: 0,0:34:54.00,0:34:56.00,Default,,0000,0000,0000,,which Dialogue: 0,0:34:56.00,0:34:59.00,Default,,0000,0000,0000,,sort of modeled a very, very simple sort of like if you're getting access to Dialogue: 0,0:34:59.00,0:35:00.00,Default,,0000,0000,0000,,the layer and you're getting help, Dialogue: 0,0:35:00.00,0:35:01.00,Default,,0000,0000,0000,, Dialogue: 0,0:35:01.00,0:35:05.00,Default,,0000,0000,0000,,that you might ask the user, to kinda say well what do you want to do next, do you Dialogue: 0,0:35:05.00,0:35:09.00,Default,,0000,0000,0000,,want to add somebody to the line or do you wanna service the next customer, and so we Dialogue: 0,0:35:09.00,0:35:11.00,Default,,0000,0000,0000,,have this way of getting their answer. Dialogue: 0,0:35:11.00,0:35:15.00,Default,,0000,0000,0000,,And if they said, okay, it's time to service the next customer then we d queue and answer Dialogue: 0,0:35:15.00,0:35:17.00,Default,,0000,0000,0000,,the question of the first person in the queue which will be the one who's been there Dialogue: 0,0:35:17.00,0:35:20.00,Default,,0000,0000,0000,,the longest, waiting the longest. And Dialogue: 0,0:35:20.00,0:35:23.00,Default,,0000,0000,0000,,if their answer was not next, we'll assume it was a name of somebody Dialogue: 0,0:35:23.00,0:35:26.00,Default,,0000,0000,0000,,just stick onto the queue, so that actually adds things to the queue. Dialogue: 0,0:35:26.00,0:35:29.00,Default,,0000,0000,0000,,So as we would go around in this loop it would continue kind of stacking things up on Dialogue: 0,0:35:29.00,0:35:31.00,Default,,0000,0000,0000,,the queue Dialogue: 0,0:35:31.00,0:35:33.00,Default,,0000,0000,0000,,until Dialogue: 0,0:35:33.00,0:35:36.00,Default,,0000,0000,0000,,the response was next and then it would start pulling them off and then we could go back Dialogue: 0,0:35:36.00,0:35:40.00,Default,,0000,0000,0000,,to adding more and whatnot, and at any given point the queue will have the name of Dialogue: 0,0:35:40.00,0:35:41.00,Default,,0000,0000,0000,,all the Dialogue: 0,0:35:41.00,0:35:43.00,Default,,0000,0000,0000,,in-queued Dialogue: 0,0:35:43.00,0:35:44.00,Default,,0000,0000,0000,,waiting questions Dialogue: 0,0:35:44.00,0:35:46.00,Default,,0000,0000,0000,,that haven't yet been handled, Dialogue: 0,0:35:46.00,0:35:49.00,Default,,0000,0000,0000,,and they will be pulled off oldest first, Dialogue: 0,0:35:49.00,0:35:51.00,Default,,0000,0000,0000,,which is the fair way to have Dialogue: 0,0:35:51.00,0:35:55.00,Default,,0000,0000,0000,,access in a waiting line. Dialogue: 0,0:35:55.00,0:35:57.00,Default,,0000,0000,0000,,So Dialogue: 0,0:35:57.00,0:35:59.00,Default,,0000,0000,0000,,just the - Dialogue: 0,0:35:59.00,0:36:04.00,Default,,0000,0000,0000,,very similar to the stack, but they - LIFO versus FIFO Dialogue: 0,0:36:04.00,0:36:07.00,Default,,0000,0000,0000,,managing to Dialogue: 0,0:36:07.00,0:36:14.00,Default,,0000,0000,0000,,come in and come out in slightly different ways. So once you Dialogue: 0,0:36:14.00,0:36:16.00,Default,,0000,0000,0000,,have kind of these four guys, right, Dialogue: 0,0:36:16.00,0:36:18.00,Default,,0000,0000,0000,,you have what are called the Dialogue: 0,0:36:18.00,0:36:20.00,Default,,0000,0000,0000,,sequential containers kind of at your disposal. Dialogue: 0,0:36:20.00,0:36:26.00,Default,,0000,0000,0000,,Most things actually just need one of those things. You need a stack of Dialogue: 0,0:36:26.00,0:36:30.00,Default,,0000,0000,0000,,keystrokes, right, or actions or web pages you visited; you need a queue of Dialogue: 0,0:36:30.00,0:36:34.00,Default,,0000,0000,0000,,jobs being queued up for the printer. You need a vector of students who are in a class, Dialogue: 0,0:36:34.00,0:36:38.00,Default,,0000,0000,0000,,you need a vector of scores on a particular exam, Dialogue: 0,0:36:38.00,0:36:41.00,Default,,0000,0000,0000,,but there's nothing to stop you from kind of combining them in new ways to Dialogue: 0,0:36:41.00,0:36:44.00,Default,,0000,0000,0000,,build even fancier things out of those building blocks, Dialogue: 0,0:36:44.00,0:36:47.00,Default,,0000,0000,0000,,that each of them is useful in it's own right, and you can actually kind of mash them Dialogue: 0,0:36:47.00,0:36:48.00,Default,,0000,0000,0000,,together to Dialogue: 0,0:36:48.00,0:36:50.00,Default,,0000,0000,0000,,create even fancier things. Dialogue: 0,0:36:50.00,0:36:55.00,Default,,0000,0000,0000,,So like I can have a vector of queue of strings that modeled the checkout lines Dialogue: 0,0:36:55.00,0:36:59.00,Default,,0000,0000,0000,,in a supermarket, where each checkout stand has it's own queue of waiting people, Dialogue: 0,0:36:59.00,0:37:01.00,Default,,0000,0000,0000,,but that there's a whole vector of them from Dialogue: 0,0:37:01.00,0:37:05.00,Default,,0000,0000,0000,,the five or ten checkout stands that I have, and so I can find out which Dialogue: 0,0:37:05.00,0:37:06.00,Default,,0000,0000,0000,,one is the Dialogue: 0,0:37:06.00,0:37:07.00,Default,,0000,0000,0000,,shortest line Dialogue: 0,0:37:07.00,0:37:09.00,Default,,0000,0000,0000,,by iterating over that vector Dialogue: 0,0:37:09.00,0:37:14.00,Default,,0000,0000,0000,,and then asking each queue what's your size the find out which is the shortest line Dialogue: 0,0:37:14.00,0:37:18.00,Default,,0000,0000,0000,,there, and picking that for the place to line up with my cart. Dialogue: 0,0:37:18.00,0:37:19.00,Default,,0000,0000,0000,, Dialogue: 0,0:37:19.00,0:37:22.00,Default,,0000,0000,0000,,If I were building a game, lets say, where there was a game board that was Dialogue: 0,0:37:22.00,0:37:23.00,Default,,0000,0000,0000,,some grid, Dialogue: 0,0:37:23.00,0:37:27.00,Default,,0000,0000,0000,,and that part of the features of this game which you could stack things Dialogue: 0,0:37:27.00,0:37:29.00,Default,,0000,0000,0000,,on top of each location, Dialogue: 0,0:37:29.00,0:37:33.00,Default,,0000,0000,0000,,then one way to model that would be a grid where each of the elements was a Dialogue: 0,0:37:33.00,0:37:36.00,Default,,0000,0000,0000,,stack itself of strings. So maybe I'm putting letters down Dialogue: 0,0:37:36.00,0:37:39.00,Default,,0000,0000,0000,,on a particular square of the board, and I can later cover that letter with Dialogue: 0,0:37:39.00,0:37:41.00,Default,,0000,0000,0000,,another letter and so on, Dialogue: 0,0:37:41.00,0:37:44.00,Default,,0000,0000,0000,,and so if I want to know what is the particular letter showing at any Dialogue: 0,0:37:44.00,0:37:45.00,Default,,0000,0000,0000,,particular grid location, Dialogue: 0,0:37:45.00,0:37:49.00,Default,,0000,0000,0000,,I can dig out the row column location, pull that stack out and then peek at what's on Dialogue: 0,0:37:49.00,0:37:51.00,Default,,0000,0000,0000,,the top. I won't be Dialogue: 0,0:37:51.00,0:37:53.00,Default,,0000,0000,0000,,able to see things that are underneath, and that might be exactly need in this Dialogue: 0,0:37:53.00,0:37:56.00,Default,,0000,0000,0000,,game, is that you can only see the things in top, Dialogue: 0,0:37:56.00,0:38:00.00,Default,,0000,0000,0000,,the things underneath are irrelevant, until maybe you pop them and they are exposed. Dialogue: 0,0:38:00.00,0:38:03.00,Default,,0000,0000,0000,,So we just layer them on top of each other, we can make them as deep as we Dialogue: 0,0:38:03.00,0:38:07.00,Default,,0000,0000,0000,,need to. It's not often they need to go past probably two levels, but you can build Dialogue: 0,0:38:07.00,0:38:10.00,Default,,0000,0000,0000,,vectors of vectors of vectors and vectors of queues of stacks of grids and Dialogue: 0,0:38:10.00,0:38:13.00,Default,,0000,0000,0000,,whatever you need to kind of get the job done. Dialogue: 0,0:38:13.00,0:38:16.00,Default,,0000,0000,0000,,There's one little C++ quirk Dialogue: 0,0:38:16.00,0:38:18.00,Default,,0000,0000,0000,,that I'm gonna mention while I'm there, Dialogue: 0,0:38:18.00,0:38:22.00,Default,,0000,0000,0000,,which is that the vector of queue of string actually has a closer - Dialogue: 0,0:38:22.00,0:38:26.00,Default,,0000,0000,0000,,a pair of those closing angle brackets that are neighbors there, Dialogue: 0,0:38:26.00,0:38:29.00,Default,,0000,0000,0000,,where I said I have a queue of string, and that I'm enclosing that to be the element Dialogue: 0,0:38:29.00,0:38:30.00,Default,,0000,0000,0000,,stored in a vector, Dialogue: 0,0:38:30.00,0:38:34.00,Default,,0000,0000,0000,,that if I put these two right next to each other, Dialogue: 0,0:38:34.00,0:38:37.00,Default,,0000,0000,0000,,which would be a natural thing to do when I was typing it out, Dialogue: 0,0:38:37.00,0:38:41.00,Default,,0000,0000,0000,,that causes the compiler to misunderstand what we want. Dialogue: 0,0:38:41.00,0:38:43.00,Default,,0000,0000,0000,,It will lead the Dialogue: 0,0:38:43.00,0:38:44.00,Default,,0000,0000,0000,,grid stack Dialogue: 0,0:38:44.00,0:38:45.00,Default,,0000,0000,0000,,string, Dialogue: 0,0:38:45.00,0:38:49.00,Default,,0000,0000,0000,,and then when it sees the string, the next thing coming up will be these two greater Dialogue: 0,0:38:49.00,0:38:52.00,Default,,0000,0000,0000,,than signs. It will read them together, Dialogue: 0,0:38:52.00,0:38:57.00,Default,,0000,0000,0000,,so it effect tokenizing it as oh, these next two things go together, Dialogue: 0,0:38:57.00,0:38:59.00,Default,,0000,0000,0000,,and they are the stream extraction operator, Dialogue: 0,0:38:59.00,0:39:01.00,Default,,0000,0000,0000,,and then it just all Dialogue: 0,0:39:01.00,0:39:04.00,Default,,0000,0000,0000,,haywire - goes haywire from there. I think that you're about - you were in the Dialogue: 0,0:39:04.00,0:39:09.00,Default,,0000,0000,0000,,middle of declaring a type and then all of a sudden you asked me to do a stream extraction. What happens, right? Dialogue: 0,0:39:09.00,0:39:11.00,Default,,0000,0000,0000,,Sad, but true, Dialogue: 0,0:39:11.00,0:39:14.00,Default,,0000,0000,0000,,and it will produce an error message, which depending on your compiler is more or Dialogue: 0,0:39:14.00,0:39:18.00,Default,,0000,0000,0000,,less helpful. The one is X-code is pretty nice, it actually says, Dialogue: 0,0:39:18.00,0:39:22.00,Default,,0000,0000,0000,,closing template, there needs to be a space between it. Dialogue: 0,0:39:22.00,0:39:25.00,Default,,0000,0000,0000,,The one in visual studio is not quite as helpful, but it's Dialogue: 0,0:39:25.00,0:39:27.00,Default,,0000,0000,0000,,just something you need to learn to look for, is that you do actually have Dialogue: 0,0:39:27.00,0:39:28.00,Default,,0000,0000,0000,,to Dialogue: 0,0:39:28.00,0:39:33.00,Default,,0000,0000,0000,,plant that extra space in there so that it will read the closer for one, and then Dialogue: 0,0:39:33.00,0:39:35.00,Default,,0000,0000,0000,,the second closer without Dialogue: 0,0:39:35.00,0:39:37.00,Default,,0000,0000,0000,,mingling them together. Dialogue: 0,0:39:37.00,0:39:40.00,Default,,0000,0000,0000,,There is an on deck proposal which shows you that C++ is a live Dialogue: 0,0:39:40.00,0:39:41.00,Default,,0000,0000,0000,,language, it's Dialogue: 0,0:39:41.00,0:39:43.00,Default,,0000,0000,0000,,evolving as we speak, but in the Dialogue: 0,0:39:43.00,0:39:47.00,Default,,0000,0000,0000,,revision of C++ as being planned, they actually want to fix this Dialogue: 0,0:39:47.00,0:39:49.00,Default,,0000,0000,0000,,so that actually it will be fine to use them Dialogue: 0,0:39:49.00,0:39:52.00,Default,,0000,0000,0000,,without the space and the right thing will happen, Dialogue: 0,0:39:52.00,0:39:55.00,Default,,0000,0000,0000,,and by changing it in the standard, it means the compiler writers will eventually kind of Dialogue: 0,0:39:55.00,0:40:00.00,Default,,0000,0000,0000,,join to be spec compliant, will actually have to change their compilers Dialogue: 0,0:40:00.00,0:40:02.00,Default,,0000,0000,0000,,to handle it properly, where as they now have Dialogue: 0,0:40:02.00,0:40:04.00,Default,,0000,0000,0000,,little incentive to do so. And Dialogue: 0,0:40:04.00,0:40:08.00,Default,,0000,0000,0000,,then I just put a little note here that as you get to these more complicated things there Dialogue: 0,0:40:08.00,0:40:09.00,Default,,0000,0000,0000,, Dialogue: 0,0:40:09.00,0:40:13.00,Default,,0000,0000,0000,,might be some more appeal to using typedef, which is a C++ way of Dialogue: 0,0:40:13.00,0:40:16.00,Default,,0000,0000,0000,,[inaudible] shorthand. Dialogue: 0,0:40:16.00,0:40:19.00,Default,,0000,0000,0000,,You can actually do this for any type in C++. The typing, Dialogue: 0,0:40:19.00,0:40:22.00,Default,,0000,0000,0000,,if you were typically something it would go up at the top of the program. Dialogue: 0,0:40:22.00,0:40:25.00,Default,,0000,0000,0000,,I say typedef and then I give the long name Dialogue: 0,0:40:25.00,0:40:28.00,Default,,0000,0000,0000,,and then I give the new short name, the nickname I'd like to give to it. So I can Dialogue: 0,0:40:28.00,0:40:32.00,Default,,0000,0000,0000,,say typedef into banana and then all through my program use banana as though Dialogue: 0,0:40:32.00,0:40:33.00,Default,,0000,0000,0000,,it were an int. Dialogue: 0,0:40:33.00,0:40:37.00,Default,,0000,0000,0000,,Okay, probably not that motivating in that situation, but when you have a Dialogue: 0,0:40:37.00,0:40:40.00,Default,,0000,0000,0000,,type name that's somehow long and complicated and a little bit awkward to reproduce throughout Dialogue: 0,0:40:40.00,0:40:42.00,Default,,0000,0000,0000,,your program, you can Dialogue: 0,0:40:42.00,0:40:45.00,Default,,0000,0000,0000,,put that type name in place and use the shorthand name to kind of add clarity Dialogue: 0,0:40:45.00,0:40:48.00,Default,,0000,0000,0000,,later. So maybe I'm using this to be Dialogue: 0,0:40:48.00,0:40:49.00,Default,,0000,0000,0000,, Dialogue: 0,0:40:49.00,0:40:51.00,Default,,0000,0000,0000,,some information about my calendar, Dialogue: 0,0:40:51.00,0:40:53.00,Default,,0000,0000,0000,,where I have the Dialogue: 0,0:40:53.00,0:40:57.00,Default,,0000,0000,0000,,months divided into days or days divided into hours, so having kinda of a two Dialogue: 0,0:40:57.00,0:40:59.00,Default,,0000,0000,0000,,layer vector here, Dialogue: 0,0:40:59.00,0:41:03.00,Default,,0000,0000,0000,,that rather than having vector of vector of ints all over the place I can us calendar T Dialogue: 0,0:41:03.00,0:41:05.00,Default,,0000,0000,0000,,to be a synonym for that Dialogue: 0,0:41:05.00,0:41:09.00,Default,,0000,0000,0000,,once I've made that declaration. Dialogue: 0,0:41:09.00,0:41:13.00,Default,,0000,0000,0000,,Let me show you just a couple of things back in the compiler space before Dialogue: 0,0:41:13.00,0:41:19.00,Default,,0000,0000,0000,,I let you guys run away to go skiing. One of the Dialogue: 0,0:41:19.00,0:41:23.00,Default,,0000,0000,0000,,things that you're likely to be working on in this case is that you're Dialogue: 0,0:41:23.00,0:41:24.00,Default,,0000,0000,0000,,learning a new Dialogue: 0,0:41:24.00,0:41:28.00,Default,,0000,0000,0000,,API, API is called Application Programming Interface, Dialogue: 0,0:41:28.00,0:41:31.00,Default,,0000,0000,0000,,it's the way you interact with the libraries, knowing what routine does what and what Dialogue: 0,0:41:31.00,0:41:33.00,Default,,0000,0000,0000,,it's name is and what it's arguments are, Dialogue: 0,0:41:33.00,0:41:36.00,Default,,0000,0000,0000,,and that's likely to be one of the things that's a little bit more of a Dialogue: 0,0:41:36.00,0:41:40.00,Default,,0000,0000,0000,,sticking point early on here, is just kind of saying, oh I know this exists in a Dialogue: 0,0:41:40.00,0:41:43.00,Default,,0000,0000,0000,,random library, but what's the name of the function, is it random numbers, is it random Dialogue: 0,0:41:43.00,0:41:45.00,Default,,0000,0000,0000,,integers, is it random it? And Dialogue: 0,0:41:45.00,0:41:46.00,Default,,0000,0000,0000,, Dialogue: 0,0:41:46.00,0:41:49.00,Default,,0000,0000,0000,,being familiar with the ways you kind find out this information. So let me Dialogue: 0,0:41:49.00,0:41:53.00,Default,,0000,0000,0000,,just give you a little hint about this; one is that you can open the header Dialogue: 0,0:41:53.00,0:41:56.00,Default,,0000,0000,0000,,files, so I just opened in this case, the grid.h header file, Dialogue: 0,0:41:56.00,0:42:00.00,Default,,0000,0000,0000,,and I can look at it and see what it says. It says, oh, here's some information, it actually has Dialogue: 0,0:42:00.00,0:42:01.00,Default,,0000,0000,0000,,some sample code here, Dialogue: 0,0:42:01.00,0:42:05.00,Default,,0000,0000,0000,,and as I scroll down Dialogue: 0,0:42:05.00,0:42:09.00,Default,,0000,0000,0000,,it'll tell me about what the class is, and then it has comma's on each of the Dialogue: 0,0:42:09.00,0:42:11.00,Default,,0000,0000,0000,,constructor and Dialogue: 0,0:42:11.00,0:42:12.00,Default,,0000,0000,0000,, Dialogue: 0,0:42:12.00,0:42:15.00,Default,,0000,0000,0000,,member function calls that tells me how it works and what errors it raises and Dialogue: 0,0:42:15.00,0:42:19.00,Default,,0000,0000,0000,,what I need to know to be able to use this call correctly. And so Dialogue: 0,0:42:19.00,0:42:23.00,Default,,0000,0000,0000,,for any of our libraries, opening the header file is likely to be an Dialogue: 0,0:42:23.00,0:42:26.00,Default,,0000,0000,0000,,illuminating experience. Dialogue: 0,0:42:26.00,0:42:29.00,Default,,0000,0000,0000,,We try to write them for humans to read, so they actually do have Dialogue: 0,0:42:29.00,0:42:31.00,Default,,0000,0000,0000,, Dialogue: 0,0:42:31.00,0:42:33.00,Default,,0000,0000,0000,,some Dialogue: 0,0:42:33.00,0:42:37.00,Default,,0000,0000,0000,,helpfulness. If you go to open a standard header file, Dialogue: 0,0:42:37.00,0:42:42.00,Default,,0000,0000,0000,,they're not quite as useful. For example, let's go look at I stream Dialogue: 0,0:42:42.00,0:42:44.00,Default,,0000,0000,0000,,and keep going. Dialogue: 0,0:42:44.00,0:42:45.00,Default,,0000,0000,0000,,You'll get Dialogue: 0,0:42:45.00,0:42:49.00,Default,,0000,0000,0000,,in there and you'll see, okay, it's typedef template car basic I stream and then there's some goo and Dialogue: 0,0:42:49.00,0:42:51.00,Default,,0000,0000,0000,,then there's a bunch of typedef's Dialogue: 0,0:42:51.00,0:42:55.00,Default,,0000,0000,0000,,and then it gets down to here, there's a little bit of information that tells Dialogue: 0,0:42:55.00,0:42:56.00,Default,,0000,0000,0000,,you about Dialogue: 0,0:42:56.00,0:42:58.00,Default,,0000,0000,0000,,what the constructor might do and stuff. Dialogue: 0,0:42:58.00,0:43:03.00,Default,,0000,0000,0000,,You can read this, but it's not - it doesn't tend to be actually Dialogue: 0,0:43:03.00,0:43:05.00,Default,,0000,0000,0000,,targeted at getting the novice up to speed about what's going on. There is Dialogue: 0,0:43:05.00,0:43:07.00,Default,,0000,0000,0000,,some information here, but Dialogue: 0,0:43:07.00,0:43:10.00,Default,,0000,0000,0000,,in those cases you may be better of using one of our references, going back Dialogue: 0,0:43:10.00,0:43:11.00,Default,,0000,0000,0000,,to the reader, Dialogue: 0,0:43:11.00,0:43:13.00,Default,,0000,0000,0000,,or looking at Dialogue: 0,0:43:13.00,0:43:16.00,Default,,0000,0000,0000,,one of the websites that we give a point or two on the reference handout that Dialogue: 0,0:43:16.00,0:43:16.00,Default,,0000,0000,0000,,just kind of Dialogue: 0,0:43:16.00,0:43:18.00,Default,,0000,0000,0000,,tries to extract the Dialogue: 0,0:43:18.00,0:43:20.00,Default,,0000,0000,0000,, Dialogue: 0,0:43:20.00,0:43:22.00,Default,,0000,0000,0000,,information you need to know as a client rather than trying to go look in here, because once you Dialogue: 0,0:43:22.00,0:43:25.00,Default,,0000,0000,0000,,get in here, oh what is gettake, and it's like what is all this stuff with these underbars Dialogue: 0,0:43:25.00,0:43:28.00,Default,,0000,0000,0000,,and stuff, it's not the best place to learn the interface, I think, from their Dialogue: 0,0:43:28.00,0:43:30.00,Default,,0000,0000,0000,,header files. Dialogue: 0,0:43:30.00,0:43:31.00,Default,,0000,0000,0000,,The other place that Dialogue: 0,0:43:31.00,0:43:34.00,Default,,0000,0000,0000,,I will note that we have is up here on the website Dialogue: 0,0:43:34.00,0:43:38.00,Default,,0000,0000,0000,,there is a documentation link, let me show you where I got to that just to remind you, Dialogue: 0,0:43:38.00,0:43:42.00,Default,,0000,0000,0000,,is up here in the top, Dialogue: 0,0:43:42.00,0:43:43.00,Default,,0000,0000,0000,,over on this side, Dialogue: 0,0:43:43.00,0:43:47.00,Default,,0000,0000,0000,,and what this is, is actually this is our header files having been run through Dialogue: 0,0:43:47.00,0:43:49.00,Default,,0000,0000,0000,,something that generates a webpage from them, so it has the same information Dialogue: 0,0:43:49.00,0:43:52.00,Default,,0000,0000,0000,,available in the header files, but it's just organized in a Dialogue: 0,0:43:52.00,0:43:55.00,Default,,0000,0000,0000,,clickable browsable way to get to things. Dialogue: 0,0:43:55.00,0:43:56.00,Default,,0000,0000,0000,,And so if you Dialogue: 0,0:43:56.00,0:44:00.00,Default,,0000,0000,0000,,dink this down and you look at the class list, you can say, yeah, tell me about queue, I'd like Dialogue: 0,0:44:00.00,0:44:04.00,Default,,0000,0000,0000,,to know more about it and then it'll give you the public member function. This Dialogue: 0,0:44:04.00,0:44:06.00,Default,,0000,0000,0000,,projector's really very Dialogue: 0,0:44:06.00,0:44:09.00,Default,,0000,0000,0000,,fuzzy, I wonder if someone can sharpen that, Dialogue: 0,0:44:09.00,0:44:10.00,Default,,0000,0000,0000,, Dialogue: 0,0:44:10.00,0:44:13.00,Default,,0000,0000,0000,,that tells you that here's the constructor, here's the n queue d queue peak, Dialogue: 0,0:44:13.00,0:44:16.00,Default,,0000,0000,0000,,there's a clear operator that empties the whole thing and then there's some other Dialogue: 0,0:44:16.00,0:44:20.00,Default,,0000,0000,0000,,operations that are involved with the deep copying that are actually explicitly named out. Dialogue: 0,0:44:20.00,0:44:23.00,Default,,0000,0000,0000,,And then if you go down, you can say, well tell me more about n queue, Dialogue: 0,0:44:23.00,0:44:27.00,Default,,0000,0000,0000,,you can come down here, it'll tell you the documentation we had that's Dialogue: 0,0:44:27.00,0:44:30.00,Default,,0000,0000,0000,,been extracted from the header files tells you about what the arguments are, what their Dialogue: 0,0:44:30.00,0:44:31.00,Default,,0000,0000,0000,,turn value is, Dialogue: 0,0:44:31.00,0:44:32.00,Default,,0000,0000,0000,, Dialogue: 0,0:44:32.00,0:44:34.00,Default,,0000,0000,0000,,what things you need to know to use that properly. Dialogue: 0,0:44:34.00,0:44:37.00,Default,,0000,0000,0000,,And so you'll probably find yourself using one or both of these, like going and actually Dialogue: 0,0:44:37.00,0:44:41.00,Default,,0000,0000,0000,,reading the header files or reading the kind of cleaned up pretty printed header files Dialogue: 0,0:44:41.00,0:44:43.00,Default,,0000,0000,0000,,just to get familiar with what those interfaces are, what the names are, and Dialogue: 0,0:44:43.00,0:44:45.00,Default,,0000,0000,0000,,how you call them Dialogue: 0,0:44:45.00,0:44:46.00,Default,,0000,0000,0000,,so Dialogue: 0,0:44:46.00,0:44:48.00,Default,,0000,0000,0000,,that when you're working you know, and have a web browser kind of up Dialogue: 0,0:44:48.00,0:44:52.00,Default,,0000,0000,0000,,aside to help you navigate that stuff Dialogue: 0,0:44:52.00,0:44:54.00,Default,,0000,0000,0000,,without too much guess work. Dialogue: 0,0:44:54.00,0:44:56.00,Default,,0000,0000,0000,,And so I just wanted to Dialogue: 0,0:44:56.00,0:44:58.00,Default,,0000,0000,0000,,show you that before I let you go. Dialogue: 0,0:44:58.00,0:45:00.00,Default,,0000,0000,0000,,Anybody questions about that? Hopefully you should feel a Dialogue: 0,0:45:00.00,0:45:01.00,Default,,0000,0000,0000,,little bit like, hey, Dialogue: 0,0:45:01.00,0:45:05.00,Default,,0000,0000,0000,,that starts to be useful. By Wednesday I'll show you map and set and Dialogue: 0,0:45:05.00,0:45:08.00,Default,,0000,0000,0000,,then you'll realize there's a lot of really cool things you can do with all these Dialogue: 0,0:45:08.00,0:45:09.00,Default,,0000,0000,0000,,objects around in your arsenal. Dialogue: 0,0:45:09.00,0:45:11.00,Default,,0000,0000,0000,,So have a good weekend, Dialogue: 0,0:45:11.00,0:45:12.00,Default,,0000,0000,0000,,enjoy the holiday, Dialogue: 0,0:45:12.00,0:45:13.00,Default,,0000,0000,0000,,come to Truman, Dialogue: 0,0:45:13.00,0:45:17.00,Default,,0000,0000,0000,,I'll see you on Wednesday.