using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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; }
}
private readonly UnicodeNameAlias[] items;
/// Initializes a new instance of the struct.
public UnicodeNameAliasCollection() { items = UnicodeNameAlias.EmptyArray; }
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(); }
public int IndexOf(UnicodeNameAlias item) { return Array.IndexOf(items, item); }
public bool Contains(UnicodeNameAlias item) { return IndexOf(item) >= 0; }
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(); }
}
}