LinkedList 11 Iterators

Поділитися
Вставка
  • Опубліковано 17 гру 2024

КОМЕНТАРІ • 15

  • @humblecoder1769
    @humblecoder1769 3 роки тому +1

    This was probably the most succinct explanation of Iterators I have seen online. Thank you for putting these lectures online.

  • @vinayprasad4659
    @vinayprasad4659 6 років тому +5

    Thank you for the wonderful series of videos. Have a question though, does the series miss Stacks and Queue 1 and 2 videos?

  • @Selim_Hasan_Raj
    @Selim_Hasan_Raj 4 роки тому

    Amazing.thank you Professor for making the world a better place

  • @yalinlu8564
    @yalinlu8564 7 років тому +4

    You write letters backward and from right to left???? That just blew my mind....

    • @dkirby6216
      @dkirby6216 7 років тому +3

      lol, thought the same thing so I checked into it. He's not, it's the high tech glass he's using www.learning.glass/

    • @lalithyagnavalkya9900
      @lalithyagnavalkya9900 4 роки тому +2

      lol he just applies mirror effect to the whole video when editing at last

  • @ZikoZigoooo
    @ZikoZigoooo 3 роки тому +1

    in the hasNext() method .. if i said return (index.next != null) , is that also considered right?

    • @thomassun3046
      @thomassun3046 2 роки тому

      if index is pointed to head, then null pointer exception

  • @anonymoustor
    @anonymoustor 4 роки тому +1

    why foreach(int x:mylist) don't work even after implementing Iteratorhelper class?

    • @arshadyusuf4803
      @arshadyusuf4803 3 роки тому +1

      Might be because you have defined "mylist" as a ListI interface type and written "implements Iterable" in the LinkedList class definition rather than the ListI interface definition.
      For the compiler to know that your ListI interface is capable of for-each loop, you have to extend the ListI interface with Iterable interface like the following:
      public interface ListI extends Iterable {.....

  • @cottonrx
    @cottonrx 5 років тому +3

    The naming of hasNext() and next() is very confusing. By definition, hasNext() "returns true if the iteration has more elements.", however it returns true if the current node is the last one which have no more elements following it...And next() method actually returns the current node instead of the next node...

    • @Alanhslc
      @Alanhslc 5 років тому

      I agree, I was wondering the same thing.

    • @shanjiang2078
      @shanjiang2078 5 років тому

      Yea, I'm confused with that part too, Can anyone please explain it?

    • @coffeedude
      @coffeedude 5 років тому +9

      hasNext( ) tells if you can keep moving forward. That is the case even at the last node because in that instance you have a pointer that goes to null. next( ) is the function that actually moves the pointer forward after returning the value it was just in. In other words, you can move forward at the last node even if you land on null so hasNext returns true and next moves forward to null, when in null you can't go anywhere so hasNext returns false and the process stops.

    • @jianxue2945
      @jianxue2945 Рік тому

      hasNext() is just saying if there is more item to move to besides the first node. Next() is moving the point to the the next element if there are more element