Don't want to loop through entire collection

At the moment, i’m doing a loop through the entire records searching for a document that appears at the end of a view. I’m trying to compare the numbers in case duplication.

What I’m trying to do now is to reduce the searching time because I know that the documents are usually at the bottom of a document collection. I don’t want to loop through the entire collection.

How can I achieve this? Thanks.

Subject: don’t want to loop through entire collection

Use NotesDocumentCollection.GetLastDocument to get the last doc in the collection, then loop backwards with NotesDocumentCollection.GetPrevDocument until you find the doc you’re looking for.

Subject: RE: don’t want to loop through entire collection

thanks for your response, Jerry. That’s what I’m doing currently. But the thing is, I need to retrieve the first of the duplicated documents.

For example,

1

2

3

4

4

5

5

I have to get the first 4 to replace with a 6. I wouldn’t know when I want to stop. But I do know I don’t have the loop the entire collection.

Is there a way I can achieve what I want to do without looping to the beginning of a collection