using System.Collections;
using System.Collections.Generic;
namespace System.Unicode
{
/// Represents a collection of name aliases.
public struct UnicodeNameAliasCollection : IList
{
/// Represents an enumerator for the class.
public struct Enumerator : IEnumerator
{
private readonly UnicodeNameAlias[] items;
private int index;
/// Initializes a new instance of the struct.
/// The items to enumerate.
internal Enumerator(UnicodeNameAlias[] items)
{
this.items = items;
this.index = -1;
}
/// Does nothing.
public void Dispose() { }
/// Gets the element in the collection at the current position of the enumerator..
/// The element in the collection at the current position of the enumerator.
public UnicodeNameAlias Current { get { return items[index]; } }
object IEnumerator.Current { get { return Current; } }
/// Advances the enumerator to the next element of the collection.
/// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
public bool MoveNext() { return index < items.Length && ++index < items.Length; }
void IEnumerator.Reset() { this.index = -1; }
}
/// Gets an empty struct.
public static readonly UnicodeNameAliasCollection Empty = new UnicodeNameAliasCollection(UnicodeNameAlias.EmptyArray);
private readonly UnicodeNameAlias[] items;
internal UnicodeNameAliasCollection(UnicodeNameAlias[] items) { this.items = items ?? UnicodeNameAlias.EmptyArray; }
/// Gets the at the specified index.
/// The .
/// The index.
/// The at the specified index.
public UnicodeNameAlias this[int index] { get { return items[index]; } }
UnicodeNameAlias IList.this[int index]
{
get { return items[index]; }
set { throw new NotSupportedException(); }
}
/// Gets the number of elements contained in the .
/// The number of elements contained in the .
public int Count { get { return items.Length; } }
bool ICollection.IsReadOnly { get { return true; } }
void ICollection.Add(UnicodeNameAlias item) { throw new NotSupportedException(); }
void IList.Insert(int index, UnicodeNameAlias item) { throw new NotSupportedException(); }
bool ICollection.Remove(UnicodeNameAlias item) { throw new NotSupportedException(); }
void IList.RemoveAt(int index) { throw new NotSupportedException(); }
void ICollection.Clear() { throw new NotSupportedException(); }
/// Determines the index of a specific item in the .
/// The object to locate in the .
/// The index of the item if found in the list; otherwise, -1.
public int IndexOf(UnicodeNameAlias item) { return Array.IndexOf(items, item); }
/// Determines whether the contains a specific value.
/// The object to locate in the .
/// if item is fount in the ; otherwise.
public bool Contains(UnicodeNameAlias item) { return IndexOf(item) >= 0; }
///
/// Copies the elements of the UnicodeNameAliasCollection to an , starting at a particular index.
///
/// The one-dimensional that is the destination of the elements to copy from UnicodeNameAliasCollection. The must have zero-based indexing.
/// The zeo-based index in array at which copy begins.
public void CopyTo(UnicodeNameAlias[] array, int arrayIndex) { items.CopyTo(array, arrayIndex); }
/// Returns an enumerator that iterates through the collection.
/// An that can be used to iterate through the collection.
public Enumerator GetEnumerator() { return new Enumerator(items); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
}