Why is movement only in most cases?

I noticed that many iterators or data readers only go as DataReader , XmlReader , IEnumerator , many more (you got this idea).

So just ask why they are only for redirection usually when I create a data iterator for my custom needs. Usually I try to add support for navigation on both sides. I agree that most of the time we don’t need a backward movement, but sometimes we need it, and so we create variables tempor something that is needed to store data at runtime.


So my questions are:

  • Why do most data-iterators only forward

  • I am mistaken when creating a reverse Iterator / Data iterator. if not, why does the infrastructure not support such support for embedded data Iterators.

  • Do we have a serious lack of performance or just not , which is considered a good design to have such an opportunity.


This question annoyed me very much, but I did not get a satisfactory answer, so I ask it here. I believe that many developers can agree with me that moving backwards can be useful sometimes.

+5
source share
1 answer

" ":

  • , .
  • , , ,
  • ( )

, , .., "". , , - .

, , ToList() .., .

, :

public static IEnumerable<int> LotsOfData() {
    var random = new Random();
    while(true) yield return random.Next();
}
  • ,

, , , - .

+9

All Articles