title
Writing an ITERATOR in C++

description
Data is everywhere! Enhance your career and acquire new skills by taking a course on DataCamp! Click here to take the first chapter of any course for FREE: https://bit.ly/2ZrYE6O (you’ll be supporting my channel too!) Patreon ► https://patreon.com/thecherno Instagram ► https://instagram.com/thecherno Twitter ► https://twitter.com/thecherno Discord ► https://thecherno.com/discord Series Playlist ► https://thecherno.com/cpp This video is sponsored by DataCamp.

detail
{'title': 'Writing an ITERATOR in C++', 'heatmap': [{'end': 643.326, 'start': 602.292, 'weight': 0.86}, {'end': 760.288, 'start': 720.41, 'weight': 0.727}, {'end': 819.312, 'start': 800.282, 'weight': 0.747}, {'end': 930.243, 'start': 906.345, 'weight': 0.878}], 'summary': 'Covers the process of writing custom iterators in c++, explaining its simplicity for simple data structures like vectors and complexity for structures like graphs. it also introduces datacamp for learning c++ and emphasizes the importance of hands-on coding for mastering c++ and creating custom iterators for enabling range-based for loops.', 'chapters': [{'end': 88.049, 'segs': [{'end': 47.971, 'src': 'embed', 'start': 18.359, 'weight': 0, 'content': [{'end': 19.68, 'text': 'We know what iterators are.', 'start': 18.359, 'duration': 1.321}, {'end': 24.863, 'text': "We've seen them in action in the C++ standard library with both the vector and the unordered map class.", 'start': 19.82, 'duration': 5.043}, {'end': 26.623, 'text': 'But what about our own data structures?', 'start': 25.043, 'duration': 1.58}, {'end': 32.945, 'text': 'When we write our own data structures, how do we write an iterator so that we can iterate through our own data structures?', 'start': 26.664, 'duration': 6.281}, {'end': 34.626, 'text': "That's what we're gonna talk about today.", 'start': 33.166, 'duration': 1.46}, {'end': 36.927, 'text': 'So is it difficult to write an iterator?', 'start': 34.806, 'duration': 2.121}, {'end': 43.949, 'text': "Well, long story, short, writing an iterator isn't particularly difficult, but it is entirely dependent on what it is you're iterating through.", 'start': 36.987, 'duration': 6.962}, {'end': 47.971, 'text': "For a vector, as you can imagine, I mean, you don't even really need to use an iterator.", 'start': 44.449, 'duration': 3.522}], 'summary': 'Writing iterators for custom data structures is not difficult, but depends on the data structure being iterated through.', 'duration': 29.612, 'max_score': 18.359, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ018359.jpg'}, {'end': 99.476, 'src': 'embed', 'start': 70.873, 'weight': 1, 'content': [{'end': 75.258, 'text': 'However, if you have a more complicated data structure, such as some kind of graph, maybe,', 'start': 70.873, 'duration': 4.385}, {'end': 81.866, 'text': 'then obviously having to visit each node and go through all of the children and the parents and all of that kind of stuff can get a little bit more involved.', 'start': 75.258, 'duration': 6.608}, {'end': 88.049, 'text': "But today, specifically, we're going to be taking a look at an example of how to write a basic iterator for our vector class,", 'start': 81.926, 'duration': 6.123}, {'end': 91.371, 'text': 'the vector class that we wrote in that episode up there.', 'start': 88.049, 'duration': 3.322}, {'end': 95.794, 'text': "But first, I wanna tell you guys all about our sponsor for today's episode, Datacamp.", 'start': 91.511, 'duration': 4.283}, {'end': 99.476, 'text': 'Datacamp is the smartest way to learn all about data science online.', 'start': 95.994, 'duration': 3.482}], 'summary': 'Tutorial on writing a basic iterator for a vector class with a mention of datacamp as the sponsor.', 'duration': 28.603, 'max_score': 70.873, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ070873.jpg'}], 'start': 0.069, 'title': 'Writing custom iterators in c++', 'summary': 'Discusses the process of writing custom iterators in c++, emphasizing that it is not particularly difficult and dependent on the data structure being iterated through, with vector iteration being relatively simple and a more complex data structure such as a graph requiring a more involved process.', 'chapters': [{'end': 88.049, 'start': 0.069, 'title': 'Writing custom iterators in c++', 'summary': 'Discusses the process of writing custom iterators in c++, emphasizing that it is not particularly difficult and dependent on the data structure being iterated through, with vector iteration being relatively simple and a more complex data structure such as a graph requiring a more involved process.', 'duration': 87.98, 'highlights': ['Writing custom iterators in C++ is not particularly difficult and depends on the data structure being iterated through, with vector iteration being relatively simple and a more complex data structure such as a graph requiring a more involved process.', 'Iterating through a vector can be achieved by keeping track of a pointer and incrementing it until the end of the vector, while for a more complex data structure like a graph, visiting each node and its children and parents can be more involved.']}], 'duration': 87.98, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ069.jpg', 'highlights': ['Writing custom iterators in C++ is not particularly difficult and depends on the data structure being iterated through, with vector iteration being relatively simple and a more complex data structure such as a graph requiring a more involved process.', 'Iterating through a vector can be achieved by keeping track of a pointer and incrementing it until the end of the vector, while for a more complex data structure like a graph, visiting each node and its children and parents can be more involved.']}, {'end': 365.339, 'segs': [{'end': 137.215, 'src': 'embed', 'start': 105.02, 'weight': 0, 'content': [{'end': 111.364, 'text': "And that's why Datacamp provides you with the tools to learn the data science and analytics skills you need to succeed in the real world.", 'start': 105.02, 'duration': 6.344}, {'end': 115.587, 'text': 'With over 300 courses from over 250 different instructors,', 'start': 111.504, 'duration': 4.083}, {'end': 121.251, 'text': 'Datacamp provides plenty of efficient bite-sized classes so that you can acquire new skills fast.', 'start': 115.587, 'duration': 5.664}, {'end': 127.353, 'text': 'I love the fact that they have immediate hands-on keyboard exercises so that you can actually build up some practical skills.', 'start': 121.531, 'duration': 5.822}, {'end': 129.532, 'text': "I'm always telling you guys how important that is.", 'start': 127.393, 'duration': 2.139}, {'end': 137.215, 'text': "Datacamp's subscription starts at $25 a month with unlimited access to all of their courses and assessment tests on any of your devices.", 'start': 129.592, 'duration': 7.623}], 'summary': 'Datacamp offers 300+ courses from 250+ instructors, with hands-on exercises, starting at $25/month.', 'duration': 32.195, 'max_score': 105.02, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0105020.jpg'}, {'end': 214.856, 'src': 'embed', 'start': 186.617, 'weight': 3, 'content': [{'end': 192.461, 'text': "One of the biggest mistakes that I see from the students that I teach is that they're all about the documentation.", 'start': 186.617, 'duration': 5.844}, {'end': 197.265, 'text': 'They are all about videos, tutorials, textbooks, that kind of stuff.', 'start': 192.521, 'duration': 4.744}, {'end': 201.728, 'text': "but they don't have much experience reading actual real world code.", 'start': 197.845, 'duration': 3.883}, {'end': 210.093, 'text': "Looking back at my personal journey as a programmer, I think that it's pretty, pretty apparent that you get to the point where the best documentation,", 'start': 201.828, 'duration': 8.265}, {'end': 214.856, 'text': "the best way for you to learn something new, is to simply look at someone else's code.", 'start': 210.093, 'duration': 4.763}], 'summary': 'Students prioritize documentation over real-world code experience.', 'duration': 28.239, 'max_score': 186.617, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0186617.jpg'}, {'end': 323.89, 'src': 'embed', 'start': 292.453, 'weight': 4, 'content': [{'end': 297.154, 'text': "but then we've also got this range-based for loop as well as the traditional iterator way.", 'start': 292.453, 'duration': 4.701}, {'end': 304.056, 'text': 'Now, these two options over here are currently not achievable whatsoever using our custom vector class.', 'start': 297.554, 'duration': 6.502}, {'end': 310.818, 'text': 'This is, of course, because all it really relies on is the index operator and the size function, which our vector does in fact provide.', 'start': 304.236, 'duration': 6.582}, {'end': 313.48, 'text': "but we can't use this at all.", 'start': 311.358, 'duration': 2.122}, {'end': 316.623, 'text': "And we obviously don't have an iterator type inside our vector class.", 'start': 313.66, 'duration': 2.963}, {'end': 317.664, 'text': "So we can't do this at all.", 'start': 316.643, 'duration': 1.021}, {'end': 323.89, 'text': 'Our goal for today is to make both of these possible by writing a custom iterator for our custom vector class.', 'start': 317.844, 'duration': 6.046}], 'summary': 'To enable range-based for loop and traditional iterator, a custom iterator needs to be written for the custom vector class.', 'duration': 31.437, 'max_score': 292.453, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0292453.jpg'}], 'start': 88.049, 'title': 'Datacamp and c++ iterators', 'summary': 'Introduces datacamp as the smartest way to learn data science online, offering over 300 courses from 250 instructors, immediate hands-on keyboard exercises, and a subscription starting at $25 a month for unlimited access. it also discusses the importance of hands-on coding and real-world code exploration in mastering c++, emphasizing the need to write custom iterators for a vector class to enable range-based for loops and traditional iterator usage.', 'chapters': [{'end': 137.215, 'start': 88.049, 'title': 'Datacamp: the smartest way to learn data science', 'summary': 'Introduces datacamp as the smartest way to learn data science online, offering over 300 courses from 250 instructors, immediate hands-on keyboard exercises, and a subscription starting at $25 a month for unlimited access.', 'duration': 49.166, 'highlights': ['Datacamp provides over 300 courses from over 250 different instructors, offering a wide range of learning opportunities.', 'Immediate hands-on keyboard exercises are available to build practical skills, emphasizing the importance of practical application.', "Datacamp's subscription starts at $25 a month, providing unlimited access to all courses and assessment tests on any device."]}, {'end': 365.339, 'start': 137.275, 'title': 'Learning c++ iterators', 'summary': 'Discusses the importance of hands-on coding and real-world code exploration in mastering c++, emphasizing the need to write custom iterators for a vector class to enable range-based for loops and traditional iterator usage.', 'duration': 228.064, 'highlights': ['The importance of hands-on coding and real-world code exploration Emphasizes the diminishing usefulness of videos, textbooks, and tutorials alone, highlighting the need for hands-on experience in reading actual real-world code to enhance learning.', 'The need to write custom iterators for a vector class Stresses the goal of enabling range-based for loops and traditional iterator usage for a custom vector class by creating a custom iterator, leveraging existing vector class implementations.', "Exploring existing vector class implementations for learning Highlights the usefulness of exploring existing vector class implementations to understand and learn from the code, particularly emphasizing the availability of iterators in the standard library's vector class."]}], 'duration': 277.29, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ088049.jpg', 'highlights': ['Datacamp provides over 300 courses from over 250 different instructors, offering a wide range of learning opportunities.', 'Immediate hands-on keyboard exercises are available to build practical skills, emphasizing the importance of practical application.', "Datacamp's subscription starts at $25 a month, providing unlimited access to all courses and assessment tests on any device.", 'The importance of hands-on coding and real-world code exploration Emphasizes the diminishing usefulness of videos, textbooks, and tutorials alone, highlighting the need for hands-on experience in reading actual real-world code to enhance learning.', 'The need to write custom iterators for a vector class Stresses the goal of enabling range-based for loops and traditional iterator usage for a custom vector class by creating a custom iterator, leveraging existing vector class implementations.']}, {'end': 1160.441, 'segs': [{'end': 448.469, 'src': 'embed', 'start': 419.274, 'weight': 0, 'content': [{'end': 422.296, 'text': "In fact, before we do that, let's take a look at their vector class.", 'start': 419.274, 'duration': 3.022}, {'end': 427.62, 'text': 'The vector class inside MSVC standard library over here has a const iterator as we looked at.', 'start': 422.356, 'duration': 5.264}, {'end': 430.081, 'text': 'And you can see that the whole concept here is pretty simple.', 'start': 427.68, 'duration': 2.401}, {'end': 434.504, 'text': 'We obviously have this kind of underscore pointer variable, which we know is a pointer.', 'start': 430.141, 'duration': 4.363}, {'end': 443.807, 'text': "And in fact if we go to it we can see that it's of type t pointer, and t pointer is essentially just the pointer type of whatever type the vector is.", 'start': 434.605, 'duration': 9.202}, {'end': 448.469, 'text': "so clearly an iterator has to be specific to whatever vector we're using in the first place.", 'start': 443.807, 'duration': 4.662}], 'summary': "Msvc standard library's vector class has a const iterator specific to the vector being used.", 'duration': 29.195, 'max_score': 419.274, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0419274.jpg'}, {'end': 500.509, 'src': 'embed', 'start': 470.217, 'weight': 1, 'content': [{'end': 472.638, 'text': 'So this is a class template over the vector.', 'start': 470.217, 'duration': 2.421}, {'end': 474.359, 'text': "That's an important detail as well.", 'start': 472.778, 'duration': 1.581}, {'end': 479.462, 'text': 'And then finally, if we look at all of these things, such as the dereference operator, you can see all it does is dereference that point.', 'start': 474.759, 'duration': 4.703}, {'end': 484.324, 'text': 'the arrow operator does the same thing, except without the dereferencing, because we still want to return a pointer here.', 'start': 479.922, 'duration': 4.402}, {'end': 491.226, 'text': 'The operator plus plus, which is one of the increment operators, the prefix increment like this that simply increments the pointer and returns this,', 'start': 484.744, 'duration': 6.482}, {'end': 496.828, 'text': 'whereas the postfix increment operator over here is actually going to take a temporary of this iterator.', 'start': 491.226, 'duration': 5.602}, {'end': 500.509, 'text': 'So in other words, just copy it, increment the current object, but return that temporary,', 'start': 496.908, 'duration': 3.601}], 'summary': 'Class template covers vector details and pointer operators.', 'duration': 30.292, 'max_score': 470.217, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0470217.jpg'}, {'end': 553.178, 'src': 'embed', 'start': 516.62, 'weight': 2, 'content': [{'end': 521.102, 'text': "We're not going to copy all of them because they, well, you can say they're all pretty simple to implement the index operator.", 'start': 516.62, 'duration': 4.482}, {'end': 522.063, 'text': "That's kind of useful.", 'start': 521.263, 'duration': 0.8}, {'end': 523.404, 'text': 'That, of course, takes in an offset.', 'start': 522.102, 'duration': 1.302}, {'end': 527.985, 'text': "And then, of course, these equals operators are very important because that's, as you can see,", 'start': 523.784, 'duration': 4.201}, {'end': 533.307, 'text': 'what we actually use here to determine whether or not we are at the end of the iterator or not.', 'start': 527.985, 'duration': 5.322}, {'end': 535.708, 'text': 'Now, finally, implementing begin and end.', 'start': 533.467, 'duration': 2.241}, {'end': 537.149, 'text': 'Also pretty simple.', 'start': 536.148, 'duration': 1.001}, {'end': 541.65, 'text': 'Begin is simply the beginning of this data buffer that we have inside the vector class.', 'start': 537.229, 'duration': 4.421}, {'end': 545.892, 'text': 'So it should be whatever memory address this first element is at.', 'start': 541.69, 'duration': 4.202}, {'end': 547.893, 'text': 'that is what begin is.', 'start': 546.432, 'duration': 1.461}, {'end': 550.496, 'text': 'Now, end is not the memory address of the last element.', 'start': 547.933, 'duration': 2.563}, {'end': 553.178, 'text': "It's actually the memory address past the last element.", 'start': 550.576, 'duration': 2.602}], 'summary': 'Implementing index, offset, and equals operators, begin and end for vector class.', 'duration': 36.558, 'max_score': 516.62, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0516620.jpg'}, {'end': 595.589, 'src': 'embed', 'start': 572.093, 'weight': 4, 'content': [{'end': 579.858, 'text': "So with that in mind, now that I've given you a nice briefing, have a go at implementing this and let's take a look at our implementation of it.", 'start': 572.093, 'duration': 7.765}, {'end': 585.162, 'text': "So over here in vector, I'm gonna start off by creating a class called vector iterator.", 'start': 580.299, 'duration': 4.863}, {'end': 592.007, 'text': "Now, using this class directly isn't really something we'll do because obviously we'll rely on begin and end to return an instance of this class.", 'start': 585.682, 'duration': 6.325}, {'end': 593.708, 'text': "We'll also make it a class template here.", 'start': 592.087, 'duration': 1.621}, {'end': 595.589, 'text': "So we'll say type name, vector.", 'start': 593.728, 'duration': 1.861}], 'summary': "Creating a class template 'vector iterator' for implementation.", 'duration': 23.496, 'max_score': 572.093, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0572093.jpg'}, {'end': 643.326, 'src': 'heatmap', 'start': 602.292, 'weight': 0.86, 'content': [{'end': 604.292, 'text': "And then I'm going to write a constructor.", 'start': 602.292, 'duration': 2}, {'end': 609.614, 'text': 'So vector iterator, and then the constructor for this needs to take in some kind of pointer.', 'start': 604.352, 'duration': 5.262}, {'end': 612.555, 'text': 'So this is the base of this iterator.', 'start': 609.894, 'duration': 2.661}, {'end': 614.996, 'text': 'Where is it currently pointing towards?', 'start': 612.715, 'duration': 2.281}, {'end': 621.399, 'text': "To make this a little bit more clear, if we scroll down, what I'm going to do is actually start implementing this vector iterator,", 'start': 615.036, 'duration': 6.363}, {'end': 623.579, 'text': 'begin and end over here straight away.', 'start': 621.399, 'duration': 2.18}, {'end': 628.701, 'text': 'So begin needs to return a new vector iterator at a particular offset.', 'start': 623.679, 'duration': 5.022}, {'end': 631.962, 'text': 'And of course, the beginning of our data block here is just mdata.', 'start': 628.761, 'duration': 3.201}, {'end': 637.524, 'text': 'So all we really need to do is return a new vector iterator here with mdata.', 'start': 632.322, 'duration': 5.202}, {'end': 643.326, 'text': "Similarly, end should be returning a vector iterator that's passed to the end.", 'start': 637.964, 'duration': 5.362}], 'summary': 'Implementing constructor and iterator methods for vector with offsets', 'duration': 41.034, 'max_score': 602.292, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0602292.jpg'}, {'end': 760.288, 'src': 'heatmap', 'start': 720.41, 'weight': 0.727, 'content': [{'end': 723.993, 'text': "We don't need to initialize it with anything because of course we're doing it in the constructor here.", 'start': 720.41, 'duration': 3.583}, {'end': 727.937, 'text': "And then scrolling down to vector, another using that I'll add is iterator.", 'start': 724.214, 'duration': 3.723}, {'end': 734.262, 'text': 'So using iterator equals vector iterator with the current vector class.', 'start': 728.357, 'duration': 5.905}, {'end': 735.584, 'text': 'like that.', 'start': 735.203, 'duration': 0.381}, {'end': 739.948, 'text': "So now we don't actually have to use vector iterator everywhere throughout our code.", 'start': 736.224, 'duration': 3.724}, {'end': 741.89, 'text': 'We just need to simply use iterator.', 'start': 740.248, 'duration': 1.642}, {'end': 745.593, 'text': 'And that also enables us to actually use the iterator like so.', 'start': 741.97, 'duration': 3.623}, {'end': 749.938, 'text': 'So vector int and then iterator, just like the standard library.', 'start': 745.653, 'duration': 4.285}, {'end': 754.242, 'text': "So, scrolling down a little bit inside our vector class, I'll get rid of vector iterator.", 'start': 750.078, 'duration': 4.164}, {'end': 760.288, 'text': "just replace it with iterator and down here as well, because iterator is, of course, the type that we've created up here.", 'start': 754.242, 'duration': 6.046}], 'summary': 'The transcript discusses using iterators to simplify code and replace vector iterators with a custom iterator class.', 'duration': 39.878, 'max_score': 720.41, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0720410.jpg'}, {'end': 827.977, 'src': 'heatmap', 'start': 800.282, 'weight': 0.747, 'content': [{'end': 807.826, 'text': 'Now the postfix operator, which is differentiated by taking an int, whereas this does nothing here, is going to return a copy of the vector iterator.', 'start': 800.282, 'duration': 7.544}, {'end': 814.53, 'text': "Because of course, we're not supposed to be modifying the object in place like we do with the prefix operator.", 'start': 808.367, 'duration': 6.163}, {'end': 819.312, 'text': "So you can see that we're actually making a copy of the vector iterator, which of course just really contains a pointer.", 'start': 814.85, 'duration': 4.462}, {'end': 820.873, 'text': "So it's not like it's expensive or anything.", 'start': 819.352, 'duration': 1.521}, {'end': 827.977, 'text': 'And then we are calling this operator here by writing this code, and finally returning this iterator copy that we made up here.', 'start': 821.373, 'duration': 6.604}], 'summary': 'Postfix operator returns a copy of vector iterator, not modifying object in place.', 'duration': 27.695, 'max_score': 800.282, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0800282.jpg'}, {'end': 930.243, 'src': 'heatmap', 'start': 906.345, 'weight': 0.878, 'content': [{'end': 912.849, 'text': 'And then this, of course, only needs to compare m pointer to whatever the other pointer is like that.', 'start': 906.345, 'duration': 6.504}, {'end': 919.254, 'text': 'And then for the not equals operator, we can simply just return the opposite of this equals other.', 'start': 913.769, 'duration': 5.485}, {'end': 923.297, 'text': 'And that ladies and gentlemen is pretty much all we really need.', 'start': 919.514, 'duration': 3.783}, {'end': 930.243, 'text': "Now, of course, there are a lot of other things you would probably want to have this support, but I'm leaving it as an exercise for you.", 'start': 923.798, 'duration': 6.445}], 'summary': 'Explains comparison and not equals operators, leaving additional support as an exercise.', 'duration': 23.898, 'max_score': 906.345, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0906345.jpg'}, {'end': 1022.387, 'src': 'embed', 'start': 993.352, 'weight': 5, 'content': [{'end': 997.775, 'text': 'But I want you to realize that this concept of iterators translates to any data structure ever.', 'start': 993.352, 'duration': 4.423}, {'end': 1004.319, 'text': 'If you have any data structure and you want to traverse it, it could be a graph, it could be some kind of tree, it could be a map.', 'start': 998.315, 'duration': 6.004}, {'end': 1009.222, 'text': 'All you really need to do is copy this, but then change what the plus plus operator does.', 'start': 1004.419, 'duration': 4.803}, {'end': 1015.024, 'text': 'Instead of just incrementing the pointer, maybe it visits some kind of child of your graph or something like that.', 'start': 1009.382, 'duration': 5.642}, {'end': 1022.387, 'text': 'Now, of course, more complicated data structures will require more complicated iterator implementations, but the concept is of course the same.', 'start': 1015.264, 'duration': 7.123}], 'summary': 'Iterators can be applied to any data structure for traversal, such as graphs, trees, or maps, by adapting the increment operation.', 'duration': 29.035, 'max_score': 993.352, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0993352.jpg'}], 'start': 365.339, 'title': 'Custom vector class and iterators', 'summary': 'Discusses the conversion to a custom vector class, emphasizing differences from c++ standard library vector. it also covers the implementation and importance of begin and end methods, and the creation of vector iterator class.', 'chapters': [{'end': 533.307, 'start': 365.339, 'title': 'C++ standard library - vector class overview', 'summary': 'Discusses the conversion of code to use a custom vector class, highlighting the differences and limitations compared to the c++ standard library vector class, with a focus on iterator implementation and functionality.', 'duration': 167.968, 'highlights': ['The C++ standard library vector class is compared with a custom vector class, highlighting differences in functionality and limitations, such as lack of support for initialized lists and range-based for loop.', 'The iterator implementation in the custom vector class is explained, emphasizing the specificity of the iterator to the vector type, the template nature of the iterator, and the functionality of operators like dereference, arrow, increment, and index.', 'The detailed overview of the iterator functionality includes explanations of increment and decrement operators, plus equals operator, index operator, and equals operators for determining the end of the iterator.']}, {'end': 1160.441, 'start': 533.467, 'title': 'Implementing begin and end for vector class', 'summary': 'Discusses the implementation of the begin and end methods for a vector class, detailing their functionality and the creation of a vector iterator class, while also highlighting the importance of iterators for traversing different data structures.', 'duration': 626.974, 'highlights': ["The chapter explains the functionality of begin and end methods for a vector class, with begin representing the beginning of the vector's memory and end representing the memory address past the end of the vector's memory. Begin represents the beginning of the vector's memory, while end represents the memory address past the end of the vector's memory.", 'A vector iterator class is created to support the implementation of begin and end methods, with a detailed explanation of the constructor and the usage of the pointer. A vector iterator class is created to support the implementation of begin and end methods, with a detailed explanation of the constructor and the usage of the pointer.', 'The chapter highlights the importance of iterators for traversing different data structures, emphasizing that the concept of iterators translates to any data structure and encourages the implementation of an iterator for an array class. The chapter emphasizes the importance of iterators for traversing different data structures and encourages the implementation of an iterator for an array class.']}], 'duration': 795.102, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/F9eDv-YIOQ0/pics/F9eDv-YIOQ0365339.jpg', 'highlights': ['The C++ standard library vector class is compared with a custom vector class, highlighting differences in functionality and limitations, such as lack of support for initialized lists and range-based for loop.', 'The iterator implementation in the custom vector class is explained, emphasizing the specificity of the iterator to the vector type, the template nature of the iterator, and the functionality of operators like dereference, arrow, increment, and index.', 'The detailed overview of the iterator functionality includes explanations of increment and decrement operators, plus equals operator, index operator, and equals operators for determining the end of the iterator.', "The chapter explains the functionality of begin and end methods for a vector class, with begin representing the beginning of the vector's memory and end representing the memory address past the end of the vector's memory.", 'A vector iterator class is created to support the implementation of begin and end methods, with a detailed explanation of the constructor and the usage of the pointer.', 'The chapter highlights the importance of iterators for traversing different data structures, emphasizing that the concept of iterators translates to any data structure and encourages the implementation of an iterator for an array class.']}], 'highlights': ['Datacamp provides over 300 courses from over 250 different instructors, offering a wide range of learning opportunities.', 'The importance of hands-on coding and real-world code exploration Emphasizes the diminishing usefulness of videos, textbooks, and tutorials alone, highlighting the need for hands-on experience in reading actual real-world code to enhance learning.', 'The need to write custom iterators for a vector class Stresses the goal of enabling range-based for loops and traditional iterator usage for a custom vector class by creating a custom iterator, leveraging existing vector class implementations.', 'The iterator implementation in the custom vector class is explained, emphasizing the specificity of the iterator to the vector type, the template nature of the iterator, and the functionality of operators like dereference, arrow, increment, and index.', 'The detailed overview of the iterator functionality includes explanations of increment and decrement operators, plus equals operator, index operator, and equals operators for determining the end of the iterator.', "The chapter explains the functionality of begin and end methods for a vector class, with begin representing the beginning of the vector's memory and end representing the memory address past the end of the vector's memory.", 'A vector iterator class is created to support the implementation of begin and end methods, with a detailed explanation of the constructor and the usage of the pointer.', 'The chapter highlights the importance of iterators for traversing different data structures, emphasizing that the concept of iterators translates to any data structure and encourages the implementation of an iterator for an array class.', 'Writing custom iterators in C++ is not particularly difficult and depends on the data structure being iterated through, with vector iteration being relatively simple and a more complex data structure such as a graph requiring a more involved process.', 'Iterating through a vector can be achieved by keeping track of a pointer and incrementing it until the end of the vector, while for a more complex data structure like a graph, visiting each node and its children and parents can be more involved.']}