Why to use ForwardIterator when I can achieve the same using a BidirectionalIterator or RandomAccessIterator...











up vote
-4
down vote

favorite












What are the performance advantages of using ForwardIterator over BidirectionalIterator or RandomAccessIterator?










share|improve this question















closed as unclear what you're asking by Nicol Bolas, Matthieu Brucher, pirho, EdChum, rsjaffe Nov 10 at 17:05


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    Your question doesn't make sense. Who is the "you" in this scenario? Are you designing a container or iterator? Are you writing an algorithm that consumes iterators? And what makes you think that "ForwardIterator" has anything to do with performance (or at least, in the way you mean it)?
    – Nicol Bolas
    Nov 10 at 16:02










  • There aren't any -- every Bidi iterator is a forward iterator, and every random-access iterator is bidi. So you can do strictly more with the stronger guarantees. Usually when something is a forward iterator, that's because that's the best it can be.
    – Kerrek SB
    Nov 10 at 16:02












  • you have the question reversed. instead you shuold ask yourself: why would i use a bidirectional iterator, when i need to iterate only in forward direction? ... and the answer is: you dont
    – user463035818
    Nov 10 at 16:07















up vote
-4
down vote

favorite












What are the performance advantages of using ForwardIterator over BidirectionalIterator or RandomAccessIterator?










share|improve this question















closed as unclear what you're asking by Nicol Bolas, Matthieu Brucher, pirho, EdChum, rsjaffe Nov 10 at 17:05


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    Your question doesn't make sense. Who is the "you" in this scenario? Are you designing a container or iterator? Are you writing an algorithm that consumes iterators? And what makes you think that "ForwardIterator" has anything to do with performance (or at least, in the way you mean it)?
    – Nicol Bolas
    Nov 10 at 16:02










  • There aren't any -- every Bidi iterator is a forward iterator, and every random-access iterator is bidi. So you can do strictly more with the stronger guarantees. Usually when something is a forward iterator, that's because that's the best it can be.
    – Kerrek SB
    Nov 10 at 16:02












  • you have the question reversed. instead you shuold ask yourself: why would i use a bidirectional iterator, when i need to iterate only in forward direction? ... and the answer is: you dont
    – user463035818
    Nov 10 at 16:07













up vote
-4
down vote

favorite









up vote
-4
down vote

favorite











What are the performance advantages of using ForwardIterator over BidirectionalIterator or RandomAccessIterator?










share|improve this question















What are the performance advantages of using ForwardIterator over BidirectionalIterator or RandomAccessIterator?







c++ c++11






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 16:03









Nicol Bolas

278k33455626




278k33455626










asked Nov 10 at 15:59









Aneesh

1356




1356




closed as unclear what you're asking by Nicol Bolas, Matthieu Brucher, pirho, EdChum, rsjaffe Nov 10 at 17:05


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by Nicol Bolas, Matthieu Brucher, pirho, EdChum, rsjaffe Nov 10 at 17:05


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    Your question doesn't make sense. Who is the "you" in this scenario? Are you designing a container or iterator? Are you writing an algorithm that consumes iterators? And what makes you think that "ForwardIterator" has anything to do with performance (or at least, in the way you mean it)?
    – Nicol Bolas
    Nov 10 at 16:02










  • There aren't any -- every Bidi iterator is a forward iterator, and every random-access iterator is bidi. So you can do strictly more with the stronger guarantees. Usually when something is a forward iterator, that's because that's the best it can be.
    – Kerrek SB
    Nov 10 at 16:02












  • you have the question reversed. instead you shuold ask yourself: why would i use a bidirectional iterator, when i need to iterate only in forward direction? ... and the answer is: you dont
    – user463035818
    Nov 10 at 16:07














  • 1




    Your question doesn't make sense. Who is the "you" in this scenario? Are you designing a container or iterator? Are you writing an algorithm that consumes iterators? And what makes you think that "ForwardIterator" has anything to do with performance (or at least, in the way you mean it)?
    – Nicol Bolas
    Nov 10 at 16:02










  • There aren't any -- every Bidi iterator is a forward iterator, and every random-access iterator is bidi. So you can do strictly more with the stronger guarantees. Usually when something is a forward iterator, that's because that's the best it can be.
    – Kerrek SB
    Nov 10 at 16:02












  • you have the question reversed. instead you shuold ask yourself: why would i use a bidirectional iterator, when i need to iterate only in forward direction? ... and the answer is: you dont
    – user463035818
    Nov 10 at 16:07








1




1




Your question doesn't make sense. Who is the "you" in this scenario? Are you designing a container or iterator? Are you writing an algorithm that consumes iterators? And what makes you think that "ForwardIterator" has anything to do with performance (or at least, in the way you mean it)?
– Nicol Bolas
Nov 10 at 16:02




Your question doesn't make sense. Who is the "you" in this scenario? Are you designing a container or iterator? Are you writing an algorithm that consumes iterators? And what makes you think that "ForwardIterator" has anything to do with performance (or at least, in the way you mean it)?
– Nicol Bolas
Nov 10 at 16:02












There aren't any -- every Bidi iterator is a forward iterator, and every random-access iterator is bidi. So you can do strictly more with the stronger guarantees. Usually when something is a forward iterator, that's because that's the best it can be.
– Kerrek SB
Nov 10 at 16:02






There aren't any -- every Bidi iterator is a forward iterator, and every random-access iterator is bidi. So you can do strictly more with the stronger guarantees. Usually when something is a forward iterator, that's because that's the best it can be.
– Kerrek SB
Nov 10 at 16:02














you have the question reversed. instead you shuold ask yourself: why would i use a bidirectional iterator, when i need to iterate only in forward direction? ... and the answer is: you dont
– user463035818
Nov 10 at 16:07




you have the question reversed. instead you shuold ask yourself: why would i use a bidirectional iterator, when i need to iterate only in forward direction? ... and the answer is: you dont
– user463035818
Nov 10 at 16:07












1 Answer
1






active

oldest

votes

















up vote
2
down vote













A more restricted iterator category doesn't normally give a performance advantage, as you'd normally use the term. Instead, it gives access to data stored in structures that aren't accessible in other ways.



Looking specifically at forward iterator, it can be used (for one example) for accessing data stored in a singly linked list, where a bidirectional iterator would normally require a doubly linked list.



Using a singly linked list could lead to a performance advantage over a doubly linked list--it only requires one pointer per node instead of two. With fewer pointers per node, you can typically expect to store more nodes in the cache, which can improve performance (considerably) by requiring fewer references to main memory.






share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    A more restricted iterator category doesn't normally give a performance advantage, as you'd normally use the term. Instead, it gives access to data stored in structures that aren't accessible in other ways.



    Looking specifically at forward iterator, it can be used (for one example) for accessing data stored in a singly linked list, where a bidirectional iterator would normally require a doubly linked list.



    Using a singly linked list could lead to a performance advantage over a doubly linked list--it only requires one pointer per node instead of two. With fewer pointers per node, you can typically expect to store more nodes in the cache, which can improve performance (considerably) by requiring fewer references to main memory.






    share|improve this answer

























      up vote
      2
      down vote













      A more restricted iterator category doesn't normally give a performance advantage, as you'd normally use the term. Instead, it gives access to data stored in structures that aren't accessible in other ways.



      Looking specifically at forward iterator, it can be used (for one example) for accessing data stored in a singly linked list, where a bidirectional iterator would normally require a doubly linked list.



      Using a singly linked list could lead to a performance advantage over a doubly linked list--it only requires one pointer per node instead of two. With fewer pointers per node, you can typically expect to store more nodes in the cache, which can improve performance (considerably) by requiring fewer references to main memory.






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        A more restricted iterator category doesn't normally give a performance advantage, as you'd normally use the term. Instead, it gives access to data stored in structures that aren't accessible in other ways.



        Looking specifically at forward iterator, it can be used (for one example) for accessing data stored in a singly linked list, where a bidirectional iterator would normally require a doubly linked list.



        Using a singly linked list could lead to a performance advantage over a doubly linked list--it only requires one pointer per node instead of two. With fewer pointers per node, you can typically expect to store more nodes in the cache, which can improve performance (considerably) by requiring fewer references to main memory.






        share|improve this answer












        A more restricted iterator category doesn't normally give a performance advantage, as you'd normally use the term. Instead, it gives access to data stored in structures that aren't accessible in other ways.



        Looking specifically at forward iterator, it can be used (for one example) for accessing data stored in a singly linked list, where a bidirectional iterator would normally require a doubly linked list.



        Using a singly linked list could lead to a performance advantage over a doubly linked list--it only requires one pointer per node instead of two. With fewer pointers per node, you can typically expect to store more nodes in the cache, which can improve performance (considerably) by requiring fewer references to main memory.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 16:13









        Jerry Coffin

        380k48459899




        380k48459899















            Popular posts from this blog

            The Sandy Post

            Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues

            Fabienne KOHLMANN