[
https://issues.apache.org/jira/browse/LUCENENET-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523752
]
Jon Palmer commented on LUCENENET-97:
-------------------------------------
Agreeded, next and hasNext is at least clear whats going on.
[ Show ยป ] Digy - 29/Aug/07 06:15 PM PS: "Implementing IEnumerator correctly"
contradicts with the logic of Hits class. It doesn't not return all the results
at onces considering the performance issues. The existance of HitIterator
class(even in Lucene java) is because of this.
Not sure what you mean by this. Implementing IEnumerator implies nothing about
getting all the resutls at once. In fact quite the opposite it says the results
will be enumerated. There are loads of classes in the .net apis that use
Ienumerator interface but aren't necessarily getting all results at once,
DataTable.Rows for example.
If the Hits class was to implement IEnumerable you might use it like this:
foreach (Hit h in hits)
{
DoSomethingWithIt(h);
if (haveEnoughResultsCondition)
{
break;
}
}
The entire point of the IEnumerator interface is that it lets implemeting class
worry about the performnace issues. The particular class might get all the
results at once, get them in a paged fashion as needed or, as in the hits
collection, get them one at a time on each call to hits.MoveNext() (which gets
implicitly called by .net when you use the foreach loop).
JP
> HitIterator does not correctly implement System.Collections.IEnumerator
> -----------------------------------------------------------------------
>
> Key: LUCENENET-97
> URL: https://issues.apache.org/jira/browse/LUCENENET-97
> Project: Lucene.Net
> Issue Type: Bug
> Environment: .NET
> Reporter: Neal Granroth
>
> method MoveNext() is supposed to increment the position within the list; it
> does not.
> method Current() is supposed to return the object at the current position,
> but not change the position within the list.
> It incorrectly moves to the next position.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.