You've already forked linux-packaging-mono
Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
84
external/referencesource/mscorlib/system/charenumerator.cs
vendored
Normal file
84
external/referencesource/mscorlib/system/charenumerator.cs
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
// ==++==
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// ==--==
|
||||
/*============================================================
|
||||
**
|
||||
** Class: CharEnumerator
|
||||
**
|
||||
**
|
||||
** Purpose: Enumerates the characters on a string. skips range
|
||||
** checks.
|
||||
**
|
||||
**
|
||||
============================================================*/
|
||||
namespace System {
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
[Serializable]
|
||||
public sealed class CharEnumerator : IEnumerator, ICloneable, IEnumerator<char>, IDisposable {
|
||||
private String str;
|
||||
private int index;
|
||||
private char currentElement;
|
||||
|
||||
internal CharEnumerator(String str) {
|
||||
Contract.Requires(str != null);
|
||||
this.str = str;
|
||||
this.index = -1;
|
||||
}
|
||||
|
||||
public Object Clone() {
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
if (index < (str.Length-1)) {
|
||||
index++;
|
||||
currentElement = str[index];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
index = str.Length;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
if (str != null)
|
||||
index = str.Length;
|
||||
str = null;
|
||||
}
|
||||
|
||||
/// <internalonly/>
|
||||
Object IEnumerator.Current {
|
||||
get {
|
||||
if (index == -1)
|
||||
throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
|
||||
if (index >= str.Length)
|
||||
throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded));
|
||||
|
||||
return currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
public char Current {
|
||||
get {
|
||||
if (index == -1)
|
||||
throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
|
||||
if (index >= str.Length)
|
||||
throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded));
|
||||
return currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentElement = (char)0;
|
||||
index = -1;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user