+ 1

How can i create the method IndexOf and LastIndexOf?

As the question says, i would like to know how to create these methods, after creating a personal LinkedList i have to implements them to use them in the main... i created all the methods that the list need except them, i would be really really grateful if you helped me.

8th Jan 2017, 10:51 PM
Mario
Mario - avatar
2 odpowiedzi
0
assuming your List contains many duplicate element similar to your parameter. Iterate your List. Then, for the IndexOf() -- get the index of the first element that is equal to you parameter. then for the LastIndexOf() -- Iterate you List. Keep track you the indices that matches you parameter. At the end of the iteration, get the last index that you have recorded. Is this helpul or you need the exact codes?
12th Jan 2017, 10:31 PM
Erwin Mesias
Erwin Mesias - avatar
0
I resolved from my self, thank you for your answer
17th Jan 2017, 2:52 PM
Mario
Mario - avatar