STL std::list | Modern Cpp Series Ep. 118

Поделиться
HTML-код
  • Опубликовано: 9 янв 2025

Комментарии • 30

  • @scullyy
    @scullyy 11 месяцев назад +4

    I've never had a use for linked lists (yet), but I have a soft spot for them. It was while learning python and creating my own linked list class, that programming finally "clicked" for me. Instead of needing to look at the tutorial and just copy/paste, I could actually create every method on my own. 🙂

  • @thestarinthesky_
    @thestarinthesky_ Год назад +2

    @24:10, i think in the 'merge' operation of a std::list, nodes from one list ( 'other' in this context) are reorganized into another list (list). This is done by adjusting the next and previous pointers of the nodes, rather than moving or copying the data they contain. This makes the merge operation more efficient than similar operations on other data structures, like arrays or vectors.
    After the merge operation, ' other' no longer contains any nodes. Its internal pointer to its first node (i.e., its "head") is set to nullptr, giving the impression that the list is now empty. In essence, 'other' as a standalone list no longer contains any elements. However, it's important to note that the nodes from 'other' have not been destroyed or removed. Instead, they've been linked into list. This is the beauty of the linked list data structure and the merge operation: it can reorganize data efficiently by manipulating pointers, without the need to physically move or copy the data. That's my understanding of merge in std::list. Thanks for the great video Mike! 👏 I am watching the whole STL series for the second time and learning new thingS.

    • @MikeShah
      @MikeShah  Год назад +1

      Awesome! Yes, linked list can really do some neat things :)

  • @AleksandreTitberidze
    @AleksandreTitberidze 9 месяцев назад +1

    Keep up the good work Mr Mike this video has been very helpful. Your teaching method is one of the best I have seen on the internet

    • @MikeShah
      @MikeShah  9 месяцев назад

      Cheers, thank you!

  • @willofirony
    @willofirony Год назад +1

    Just a heads uo; Splice can also be used to move an element within a list. Details in cppreference std::list::splice.

    • @MikeShah
      @MikeShah  Год назад

      Neat -- it would be a flaw in the design in my opinion if we could not splice within the same list.

  • @mehedihassan-pf6yh
    @mehedihassan-pf6yh Год назад +3

    youre one of the different teacher sir, please show us something that others don't share , like u did in this video

    • @MikeShah
      @MikeShah  Год назад +1

      Cheers, thank you for the kind words!

    • @mehedihassan-pf6yh
      @mehedihassan-pf6yh Год назад +2

      thanks if you touch any topics ,please discuss deeply by showing cpprefferance , and this helps learning when u talk half an hour and show everything inside out.god bless u@@MikeShah

  • @thestarinthesky_
    @thestarinthesky_ Год назад +1

    @4:16 When you say as long as we have iterator , this also mean we are having O(i) if i is the position of the list in the std::list object right? it wouldn't be O(1) if we calculate iterator part too.

    • @MikeShah
      @MikeShah  Год назад +1

      Correct, if we have an iterator then we can insert in O(1)

    • @thestarinthesky_
      @thestarinthesky_ Год назад +1

      @@MikeShah Thank you so much.

  • @viliamjr
    @viliamjr 8 месяцев назад

    Amazing tutorials about STL, very handy!

  • @mehedihassan-pf6yh
    @mehedihassan-pf6yh Год назад +1

    keep going dont stop mate

    • @MikeShah
      @MikeShah  Год назад +1

      More on the way 🙂

  • @ghulam2545
    @ghulam2545 Год назад +4

    Helpful and informative, thanks for continuing the series. How about having light theme over dark for tutorials.

    • @MikeShah
      @MikeShah  Год назад +1

      Cheers. Will consider that

  • @qcnck2776
    @qcnck2776 Год назад +2

    Thanks much!

  • @codigo-nodosyvfx
    @codigo-nodosyvfx Год назад +1

    Great video

  • @VoidloniXaarii
    @VoidloniXaarii Год назад +1

    You're so cool, thanks again

    • @MikeShah
      @MikeShah  Год назад +1

      Cheers!

    • @VoidloniXaarii
      @VoidloniXaarii Год назад +1

      ​@@MikeShahstill learning going thought it again. Thank you for making.. reusable code 😅

    • @MikeShah
      @MikeShah  Год назад +1

      @@VoidloniXaarii cheers! Enjoy!

  • @minecraftcookie2929
    @minecraftcookie2929 10 дней назад +1

    Hey mike I have a question -> First look at this code ->
    int main()
    {
    std::list li = { 321, 432, 12, 34, 531 };
    std::list::iterator it = li.begin();
    for(it; it != li.end(); it++){
    std::cout

    • @MikeShah
      @MikeShah  9 дней назад +1

      Hmm, perhaps after the final node, the 'next' pointer points back to the head then -- that seems to be the behavior I'm getting here: godbolt.org/z/fYcv1Yjz7 This still is behavior that I would not tend to rely on :)

    • @minecraftcookie2929
      @minecraftcookie2929 8 дней назад +1

      @@MikeShah Thank you mike. I guess i will rule out this behavior as some kind of optimization maybe to prevent accessing non-reserved memory.