本文整理汇总了C#中IEnumerator.Next方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerator.Next方法的具体用法?C# IEnumerator.Next怎么用?C# IEnumerator.Next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerator
的用法示例。
在下文中一共展示了IEnumerator.Next方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Marshal
public object Marshal(IEnumerator<string> currentArgument)
{
try
{
return currentArgument.Next();
}
catch (InvalidOperationException)
{
throw new ArgsException(ErrorCode.MissingString);
}
}
示例3: TestFieldNonExistent
public void TestFieldNonExistent()
{
try
{
indexReader = IndexReader.Open(store, true);
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(); }
}
}
示例4: Marshal
public object Marshal(IEnumerator<string> currentArgument)
{
string parameter = null;
try
{
parameter = currentArgument.Next();
return Int32.Parse(parameter);
}
catch (InvalidOperationException)
{
throw new ArgsException(ErrorCode.MissingInteger);
}
catch (FormatException)
{
throw new ArgsException(ErrorCode.InvalidInteger, errorParameter: parameter);
}
}
示例5: Marshal
public object Marshal(IEnumerator<string> currentArgument)
{
string parameter = null;
try
{
parameter = currentArgument.Next();
return double.Parse(parameter, CultureInfo.InvariantCulture);
}
catch (InvalidOperationException)
{
throw new ArgsException(ErrorCode.MissingDouble);
}
catch (FormatException)
{
throw new ArgsException(ErrorCode.InvalidDouble, errorParameter: parameter);
}
}
示例6: 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(); }
}
}
示例7: 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(); }
}
}
示例8: 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(); }
}
}
示例9: MakeLeafNodes
private IEnumerable<KeyValuePair<byte[], ulong >> MakeLeafNodes(ulong txnId, IEnumerator<KeyValuePair<byte[], byte[]>> orderedValues, BrightstarProfiler profiler = null)
{
ILeafNode prevNode = MakeLeafNode(txnId, orderedValues.Next(_leafLoadFactor));
if (prevNode.KeyCount < _leafLoadFactor)
{
// There were only enough values to fill a single leaf node
yield return WriteNode(txnId, prevNode, profiler);
yield break;
}
ILeafNode nextNode = MakeLeafNode(txnId, orderedValues.Next(_leafLoadFactor));
do
{
if (nextNode.KeyCount >= _config.LeafSplitIndex)
{
yield return WriteNode(txnId, prevNode, profiler);
}
else
{
// Final leaf node needs to share some values from the previous node we created
nextNode.RedistributeFromLeft(txnId, prevNode);
yield return WriteNode(txnId, prevNode, profiler);
}
prevNode = nextNode;
var nextKeys = orderedValues.Next(_leafLoadFactor).ToList();
nextNode = nextKeys.Count > 0 ? MakeLeafNode(txnId, nextKeys) : null;
} while (nextNode != null);
yield return WriteNode(txnId, prevNode, profiler);
}
示例10: 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());
}
示例11: MakeInternalNode
private InternalNode MakeInternalNode(KeyValuePair<byte[], ulong> firstChild, IEnumerator<KeyValuePair<byte[], ulong>> enumerator, int internalBranchFactor)
{
var nodePage = _pageStore.Create();
var childPointers = new List<ulong>(internalBranchFactor + 1) {firstChild.Value};
var keys = new List<byte[]>();
var kvpList = enumerator.Next(_internalBranchFactor).ToList();
foreach (var keyValuePair in kvpList)
{
childPointers.Add(keyValuePair.Value);
var key = new byte[_config.KeySize];
Array.Copy(keyValuePair.Key, key, _config.KeySize);
keys.Add(key);
}
/*
for (int i = 0; i < kvpList.Count; i++)
{
childPointers.Add(enumerator.Current.Value);
keys.Add(new byte[_config.KeySize]);
Array.Copy(enumerator.Current.Key, keys[i], _config.KeySize);
}
*/
return new InternalNode(nodePage, keys, childPointers, _config);
}
示例12: 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());
}