本文整理汇总了C#中LinkedList.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedList.GetEnumerator方法的具体用法?C# LinkedList.GetEnumerator怎么用?C# LinkedList.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.GetEnumerator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getLCSGrid
public static int[,] getLCSGrid(LinkedList<Behavior> sequenceA, LinkedList<Behavior> sequenceB)
{
int[,] grid = new int[sequenceA.Count + 1, sequenceB.Count + 1];
int i;
int j;
for (i = 0; i < grid.GetLength(0); i++)
{
grid[i, 0] = 0;
}
for (i = 0; i < grid.GetLength(1); i++)
{
grid[0, i] = 0;
}
i = 1;
for (LinkedList<Behavior>.Enumerator a = sequenceA.GetEnumerator(); a.MoveNext(); i++)
{
j = 1;
for (LinkedList<Behavior>.Enumerator b = sequenceB.GetEnumerator(); b.MoveNext(); j++)
{
if (a.Current.compareTo(b.Current) == 0)
{
grid[i, j] = grid[i-1, j-1] + 1;
}
else
{
grid[i, j] = Math.Max(grid[i, j - 1], grid[i - 1, j]);
}
}
}
return grid;
}
示例2: Main
private static void Main()
{
// LinkedList<string> -sasto moje zaradi polimorfizma
IEnumerable<string> list = new LinkedList<string>(
"1st element",
new LinkedList<string>("2nd element", new LinkedList<string>("3rd element")));
foreach (var item in list)
{
Console.WriteLine(item);
}
// ot metoda v LinkedList
var enumerator = list.GetEnumerator();
// pak se vliza v sastiat method, v koito i otogore vlizahme, defakto dolnite redove zamestvat foreacha
while (enumerator.MoveNext())
{
Console.WriteLine(enumerator.Current);
}
// enumerator.Reset();
var nums = new CustomList<int>();
nums.Add(5);
nums.Add(2);
nums.Add(4);
nums.Add(2);
nums.Add(1);
foreach (var num in nums)
{
Console.WriteLine(num);
}
}
示例3: getMissingFilesForWidget
private ArrayList getMissingFilesForWidget(LinkedList<FileInfo> filesCurWidget, ArrayList files)
{
IEnumerator ienumf = filesCurWidget.GetEnumerator();
ArrayList missingFiles = new ArrayList();
bool found = false;
while (ienumf.MoveNext())
{
FileInfo finfo = (FileInfo)ienumf.Current;
found = false;
IEnumerator ienuml = files.GetEnumerator();
while (ienuml.MoveNext())
{
string localPath = (string)ienuml.Current;
if (localPath == Utils.normalizePathname(finfo.localPath))
{
found = true;
break;
}
}
if ( !found )
{
missingFiles.Add(finfo.localPath);
}
}
return missingFiles;
}
示例4: AddDeclarations
public void AddDeclarations(LinkedList<CSSDeclaration> declarations)
{
IEnumerator<CSSDeclaration> e = declarations.GetEnumerator();
while (e.MoveNext()) {
p_Declarations.AddLast(e.Current);
}
e.Dispose(); ;
}
示例5: SyntaxAnalyser
public SyntaxAnalyser(string inputText)
{
input = new LinkedList<string>();
foreach (char s in inputText)
{
input.AddLast(s.ToString());
}
isCorrect = true;
enumerator = input.GetEnumerator();
enumerator.Dispose();
}
示例6: Main
static void Main(string[] args)
{
var k = 30;
var names = File.ReadLines("first.txt");
var list = new LinkedList<string>();
foreach(var name in names){
list.AddLast(name);
}
var e1 = list.GetEnumerator();
var e2 = list.GetEnumerator();
var i = 0;
while(e1.MoveNext()!=false){
i++;
if (i>=k){
e2.MoveNext();
}
}
Console.WriteLine(e2.Current);
}
示例7: should_get_value_using_current_property
public void should_get_value_using_current_property()
{
var collection = new LinkedList<int>(new[] {1, 2, 3});
LinkedList<int>.Enumerator enumerator = collection.GetEnumerator();
enumerator.MoveNext();
int currentValue = enumerator.Current;
// change the variable value to fix the test.
const int expectedCurrentValue = 2;
Assert.Equal(expectedCurrentValue, currentValue);
}
示例8: LinkedListEnumerator
public static void LinkedListEnumerator(long[] data)
{
LinkedList<long> testList = new LinkedList<long>();
foreach (var l in data)
{
testList.Add(l);
}
var testlistenum = testList.GetEnumerator();
var dataenum = data.GetEnumerator();
for (int i = 0; i < data.Length; i++)
{
testlistenum.MoveNext();
dataenum.MoveNext();
Assert.AreEqual(testlistenum.Current, dataenum.Current);
}
}
示例9: IncrementToken
public override bool IncrementToken()
{
if (Cache == null)
{
// fill cache lazily
Cache = new LinkedList<AttributeSource.State>();
FillCache();
Iterator = Cache.GetEnumerator();
}
if (!Iterator.MoveNext())
{
// the cache is exhausted, return false
return false;
}
// Since the TokenFilter can be reset, the tokens need to be preserved as immutable.
RestoreState(Iterator.Current);
return true;
}
示例10: TestEmptyLinkedListEnumerator
public void TestEmptyLinkedListEnumerator()
{
LinkedList<Object> foo = new LinkedList<Object> ();
IEnumerator<Object> enr = foo.GetEnumerator ();
Assert.IsFalse (enr.MoveNext ());
}
示例11: avg
private double avg(LinkedList<double> list)
{
double sum = 0, count = 0;
LinkedList<double>.Enumerator a = list.GetEnumerator();
while(a.MoveNext()){
sum += a.Current;
count++;
}
return sum/count;
}
示例12: EnumerableTest
[TestMethod] // IEnumerable
public void EnumerableTest()
{
LinkedList<object> data = new LinkedList<object>();
data.Append(8);
data.Append(6);
data.GetEnumerator();
}
示例13: findCore
private void findCore(string query, bool deep, bool matchCase, bool matchWhole, LinkedList<Node> list, LinkedList<MarkupElement> buffer, bool textFind, bool attributeFind, bool attributeValue)
{
//check for valid call
//if it's a text find AND attribute find, we actually call findCore twice
//one to match attributes and pipe the result into a text find call
if (textFind && attributeFind) {
LinkedList<MarkupElement> pipe = new LinkedList<MarkupElement>();
findCore(query, deep, matchCase, matchWhole, list, pipe, false, attributeFind, attributeValue);
findCore(query, deep, matchCase, matchWhole, pipe, buffer, true, false, false);
return;
}
if (!attributeFind && attributeValue) {
throw new Exception("Illigal call, attributeValue cannot be true when attributeFind is false.");
}
//case insensitive? make the query lower case so we can compare two lower case strings together
if (!matchCase) { query = query.ToLower(); }
//enumerate over all the child nodes
IEnumerator<Node> children = list.GetEnumerator();
while (children.MoveNext()) {
MarkupElement current = children.Current as MarkupElement;
bool match = false;
//is it an attribute find?
//if so, iterate over all the attributes and find the name
if (attributeFind) {
IEnumerator<MarkupAttribute> attrEnum = current.Attributes.GetEnumerator();
while (attrEnum.MoveNext()) {
MarkupAttribute attr = attrEnum.Current;
string attrCompare = (attributeValue ? attr.Value : attr.Name);
match = matchCore(attrCompare, query, matchCase, matchWhole);
if (match) { break; }
}
//clean up
attrEnum.Dispose();
}
//text find?
else if (textFind && current is MarkupTextElement) {
match = matchCore(
(current as MarkupTextElement).Text,
query,
matchCase,
matchWhole);
}
else {
//tag compare
match = matchCore(current.TagName, query, matchCase, matchWhole);
}
//is it a match?
if (match) {
buffer.AddLast(current);
}
//recursive?
if (deep) {
findCore(
query,
deep,
matchCase,
matchWhole,
current.Children,
buffer,
textFind,
attributeFind,
attributeValue);
}
}
//clean up
children.Dispose();
}
示例14: Parse
//.........这里部分代码省略.........
//read the name
byte* attrNamePtr, attrNamePtrEnd;
if (readName(ref data, dataEnd, out attrNamePtr, out attrNamePtrEnd, false, tagHasQM, ref closeCharFound)) { break; }
//skip to the value
if (Helpers.SkipWhitespaces(ref data, dataEnd)) { break; }
//read the value
byte* attrValuePtr = data, attrValuePtrEnd = (byte*)NULLPTR;
if (*data == '=') {
data++;
if (Helpers.SkipWhitespaces(ref data, dataEnd)) { break; }
//read the value
readStringValue(ref data, dataEnd, out attrValuePtr, out attrValuePtrEnd, tagHasQM, ref closeCharFound);
}
//add the attribute
string valueString =
(attrValuePtrEnd == (byte*)0) ? null :
Helpers.ReadString(attrValuePtr, attrValuePtrEnd, encoder);
element.AddAttribute(
Helpers.ReadString(attrNamePtr, attrNamePtrEnd, encoder),
valueString);
}
#endregion
//skip to the end of the tag
while (data < dataEnd && *data != MarkupTAG_CLOSE) {
if (*data == MarkupTAG_SCOPECLOSE) { tagDoesTerminate = true; }
data++;
}
if (*data == MarkupTAG_CLOSE) { closeCharFound = true; }
#region create inner text if required
//is there text to be added before the element is added?
if (innerTextBufferPtr != innerTextBufferPtrEnd) {
//create the text element
if (!isEmptyData(innerTextBufferPtr, innerTextBufferPtrEnd - 1)) {
string str = Helpers.ReadString(innerTextBufferPtr, innerTextBufferPtrEnd, encoder);
if (current is MarkupTextElement) {
(current as MarkupTextElement).Text = str;
}
else {
current.AddChild(factory.CreateText(textTagName, str));
}
}
}
//reset
innerTextBufferPtr = data + 1;
innerTextBufferPtrEnd = data + 1;
#endregion
//is this a valid tag?
if (!closeCharFound) {
//just presume what we just processed was text
innerTextBufferPtrEnd = data;
continue;
}
//add the tag
current.AddChild(element);
//change the current name to the new element
//but only if the tag has not been terminated immidiately
//(otherwise there is no point adding to it.)
if (!tagDoesTerminate) {
current = element;
currentNamePtr = element.TagName;
currentName = currentNameList.AddLast(currentNamePtr);
}
}
innerTextBufferPtrEnd++;
data++;
}
//is there text left?
if (innerTextBufferPtrEnd != innerTextBufferPtr &&
innerTextBufferPtrEnd > innerTextBufferPtr &&
!isEmptyData(innerTextBufferPtr, innerTextBufferPtrEnd - 1)) {
current.AddChild(factory.CreateText(
textTagName,
Helpers.ReadString(
innerTextBufferPtr,
innerTextBufferPtrEnd,
encoder)));
}
//clean up
IEnumerator<STRPTR> destructCurrentNameList = currentNameList.GetEnumerator();
while (destructCurrentNameList.MoveNext()) {
destructCurrentNameList.Current.Destroy();
}
destructCurrentNameList.Dispose();
}
示例15: substituteExist
private bool substituteExist(char name, LinkedList<ArithmeticSubstitute> subs, out ArithmeticSubstitute found)
{
found = default(ArithmeticSubstitute);
//look for the name
IEnumerator<ArithmeticSubstitute> e = subs.GetEnumerator();
while (e.MoveNext()) {
ArithmeticSubstitute current = e.Current;
if (current.Name == name) {
e.Dispose();
found = current;
return true;
}
}
//not found
e.Dispose();
return false;
}