本文整理汇总了C#中IEnumerator.HasNext方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerator.HasNext方法的具体用法?C# IEnumerator.HasNext怎么用?C# IEnumerator.HasNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerator
的用法示例。
在下文中一共展示了IEnumerator.HasNext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyStreamsToFolder
/// <exception cref="System.IO.IOException"></exception>
public static void CopyStreamsToFolder(IEnumerator<KeyValuePair<string, InputStream >> streams, FilePath folder)
{
while (streams.HasNext())
{
KeyValuePair<string, InputStream> entry = streams.Next();
FilePath file = new FilePath(folder, entry.Key);
CopyStreamToFile(entry.Value, file);
}
}
示例2: TestFieldNonExistent
public void TestFieldNonExistent()
{
try
{
indexReader = IndexReader.Open(store);
ld = new LuceneDictionary(indexReader, "nonexistent_field");
it = ld.GetWordsIterator();
AssertFalse("More elements than expected", it.HasNext());
AssertTrue("Nonexistent element is really null", it.Next() == null);
}
finally
{
if (indexReader != null) { indexReader.Close(); }
}
}
示例3: TestFieldAaa
public void TestFieldAaa()
{
try
{
indexReader = IndexReader.Open(store);
ld = new LuceneDictionary(indexReader, "aaa");
it = ld.GetWordsIterator();
AssertTrue("First element doesn't exist.", it.HasNext());
AssertTrue("First element isn't correct", it.Next().Equals("foo"));
AssertFalse("More elements than expected", it.HasNext());
AssertTrue("Nonexistent element is really null", it.Next() == null);
}
finally
{
if (indexReader != null) { indexReader.Close(); }
}
}
示例4: TestFieldContents_2
public void TestFieldContents_2()
{
try
{
indexReader = IndexReader.Open(store);
ld = new LuceneDictionary(indexReader, "contents");
it = ld.GetWordsIterator();
// hasNext() should have no side effects //{{DIGY}} But has. Need a fix?
//AssertTrue("First element isn't were it should be.", it.HasNext());
//AssertTrue("First element isn't were it should be.", it.HasNext());
//AssertTrue("First element isn't were it should be.", it.HasNext());
// just iterate through words
AssertTrue("First element isn't correct", it.Next().Equals("Jerry"));
AssertTrue("Second element isn't correct", it.Next().Equals("Tom"));
AssertTrue("Nonexistent element is really null", it.Next() == null);
// hasNext() should still have no side effects ...
AssertFalse("There should be any more elements", it.HasNext());
AssertFalse("There should be any more elements", it.HasNext());
AssertFalse("There should be any more elements", it.HasNext());
// .. and there are really no more words
AssertTrue("Nonexistent element is really null", it.Next() == null);
AssertTrue("Nonexistent element is really null", it.Next() == null);
AssertTrue("Nonexistent element is really null", it.Next() == null);
}
finally
{
if (indexReader != null) { indexReader.Close(); }
}
}
示例5: TestFieldContents_1
public void TestFieldContents_1()
{
try
{
indexReader = IndexReader.Open(store);
ld = new LuceneDictionary(indexReader, "contents");
it = ld.GetWordsIterator();
AssertTrue("First element doesn't exist.", it.HasNext());
AssertTrue("First element isn't correct", it.Next().Equals("Jerry"));
AssertTrue("Second element doesn't exist.", it.HasNext());
AssertTrue("Second element isn't correct", it.Next().Equals("Tom"));
AssertFalse("More elements than expected", it.HasNext());
AssertTrue("Nonexistent element is really null", it.Next() == null);
ld = new LuceneDictionary(indexReader, "contents");
it = ld.GetWordsIterator();
int counter = 2;
while (it.HasNext())
{
it.Next();
counter--;
}
AssertTrue("Number of words incorrect", counter == 0);
}
finally
{
if (indexReader != null) { indexReader.Close(); }
}
}
示例6: CompareIterators
private void CompareIterators(IEnumerator it1, IEnumerator it2)
{
while (it1.HasNext())
{
NUnit.Framework.Assert.AreEqual(it1.Next(), it2.Next());
}
NUnit.Framework.Assert.IsFalse(it2.HasNext());
}
示例7: CompareIterators
private void CompareIterators(IEnumerator it1, IEnumerator it2)
{
NUnit.Framework.Assert.IsTrue(map.Count == 4);
while (it1.HasNext())
{
NUnit.Framework.Assert.AreEqual(it1.Next(), it2.Next());
it1.Remove();
it2.Remove();
}
NUnit.Framework.Assert.IsTrue(map.IsEmpty());
}