lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Palmer (JIRA)" <>
Subject [jira] Commented: (LUCENENET-97) HitIterator does not correctly implement System.Collections.IEnumerator
Date Wed, 29 Aug 2007 22:50:31 GMT


Jon Palmer commented on LUCENENET-97:

Right in that usage it clearly works but that entirely broken and not the correct implementation
of IEnumerator:

it going to create weird issues if I use it like this

           HitIterator iterator = (HitIterator)hits.Iterator(); 
            while (iterator.MoveNext()) 
                Hit h = (Hit)iterator.Current; 


Now the IEnumerator contract says the SomeOtherMethod should be able to call iterator.Current
as many times as it wants without any affect. With the existing broken implementation you
are force only to every call Current once. 

Btw the Lucene.Net.Search.Hits should clearly implement IEnumerable by implementing the interface
with the simple method:

public IEnumerator GetEnumerator()
           return Iterator();

then you can do nice replace the ugly while loop above with nice .net things like this:

      foreach(Hit h in hits)

> HitIterator does not correctly implement System.Collections.IEnumerator
> -----------------------------------------------------------------------
>                 Key: LUCENENET-97
>                 URL:
>             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.

View raw message