Mike, this whole series has been incredibly relevant to me for a project I'm currently working on, and your explanation has dramatically enhanced my understanding. I find your explanations to be some of the best on RU-vid and I don't understand how you're not getting more views. I'll certainly continue to watch!
29:09 Why are you iterating through the list if you can just call list.remove(observer) immediately? Since you're passing through the observer and not li.
Hmm, I believe I wanted to make sure to remove the exact observer. I think remove takes in an iterator or a value, but I want to remove a specific observer. I suppose it should still work with remove, even on a forward_list -- try it out!
@@MikeShah Hi, great series btw and thank you for responding. But back to my question, I meant that in the if statement you're checking if li == observer and then you're removing "observer", but my confusion stems from the fact that: why go through the additional steps of iterating and condition check when you could call it from the get go? Since you're not passing li to be removed, I'm wondering if these steps are redundant or if they serve an actual purpose. Thanks again.
I think you're right -- that is less efficient. I think I should call list.remove(li) directrly since we have an iterator to the position (that should be constant time). Otherwise, as suggested, could just call list.remove(some_value) and that should remove the value after iterating it if it exists.@@jalennaarden2553