Question

In: Computer Science

Discuss the differences between a list's regular iterator, which supports the use of a "for" loop,...

Discuss the differences between a list's regular iterator, which supports the use of a "for" loop, and its other list iterator that supports position-based operations. Discuss the advantages and disadvantages of each.

Solutions

Expert Solution

Both iterator or list iterator is same for purpose ..i.e is to iterate through the list we have.
but the major difference between list iterator and iterator is quite simple

list iterator can iterate in both direction forward and backward direction ..it can move previous and even next.
but in regular iterator..it can iterate only in one direction.that is only unidirection.it can move only forward .
and one thing we should keep in mind that ..list iterator itarates only for list..but not for set map etc.
where as regular iterator works beyond than that.it uses form list ,map.set etc.

listiterator comes up with other benifit is..it can modify the data inside list during iteration like adding removing etc.
but in regualar iterator we cannot add element at a time of itearation..we can remove element ..

and another advantage of listiterator is..listiterator can get curent index position when traversing but ..normal iterator cannot give that ..as it get the index positon by using prev and next but normal iterator doesn not

iterator is not a class it is an interface and even listiterator is also an interface.

both are comes in java 1.2 and part of collection framework


Related Solutions

Discuss the fundamental differences between the Classical and Keynesian schools of macroeconomics. Use these differences to...
Discuss the fundamental differences between the Classical and Keynesian schools of macroeconomics. Use these differences to motivate a discussion of how inflationary and recessionary gaps can be eliminated through the use of discretionary fiscal policy. Use a graphical analysis and conclude by considering the long-run ramifications of adopting a fiscal budget that is sensitive to movements in the business cycle.
Made differences between the financial statements of a non-profit and regular? Please use an example from...
Made differences between the financial statements of a non-profit and regular? Please use an example from each financial statement
Discuss the differences between the use of ACLs versus the use of firewalls for network security....
Discuss the differences between the use of ACLs versus the use of firewalls for network security. In what situations would the use of ACLs be an advantage over using a hardware firewall? Discuss the differences between an IDS and an IPS. Discuss examples of organizations who might want to implement an IPS over an IDS.
Create a method on the Iterator class called forEach, which appropriate behavior. This method should use...
Create a method on the Iterator class called forEach, which appropriate behavior. This method should use next(), and should not use this._array.forEach! Take note of what should happen if you call forEach twice on the same Iterator instance. The estimated output is commented below In javascript please class Iterator { constructor(arr){ this[Symbol.iterator] = () => this this._array = arr this.index = 0 } next(){ const done = this.index >= this._array.length const value = this._array[this.index++] return {done, value} } //YOUR WORK...
What are the differences between regular and irregular items on an income statement? What are the...
What are the differences between regular and irregular items on an income statement? What are the requirements for items to qualify as irregular? What are some examples of irregular items? What is the effect of irregular items on an investor’s analysis of a company?
Discuss the differences between utilization and efficiency as measures of system performance. Which (if any) is...
Discuss the differences between utilization and efficiency as measures of system performance. Which (if any) is the most useful measure for an operations manager? Why?
consider the use of mergers verses corporate alliances in growing a company. Discuss the differences between...
consider the use of mergers verses corporate alliances in growing a company. Discuss the differences between a merger and a corporate alliance. In 5 sentences. Explain the pros and cons of both and how taxes influence the use of each approach.
Discuss the main differences (minimum 3) between the firewall and IDS? Use the diagram to illustrate...
Discuss the main differences (minimum 3) between the firewall and IDS? Use the diagram to illustrate the components for the types of IDS vs firewall. Use two or three sentences to discuss the differences based on your understanding?(no more than 300 words
Discuss the differences and similarities between these three business forms : 1. Differences and similarities between...
Discuss the differences and similarities between these three business forms : 1. Differences and similarities between LLC in USA vs SARL in Lebanon 2. Corporation in USA vs S.A.L in Lebanon 3. General Partnership in USA vs. Unlimited Partnership in Lebanon
What is close loop and open loop in controls, what are the differences and what are...
What is close loop and open loop in controls, what are the differences and what are their similarities. Please illustrate using a block diagram if possible
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT