// WroteResCollection.cs

namespace Twin
{
	using System;
	using System.Collections;

	/// <summary>
	/// WroteResÌRNVð\·
	/// </summary>
	public class WroteResCollection : CollectionBase
	{
		private int totalSize;

		/// <summary>
		/// wèµ½CfbNXÌXððæ¾
		/// </summary>
		public WroteRes this[int index] {
			get {
				return (WroteRes)List[index];
			}
		}

		/// <summary>
		/// XÌvTCYðæ¾
		/// </summary>
		public int TotalSize {
			get {
				return totalSize;
			}
		}

		/// <summary>
		/// WroteResCollectionNXÌCX^Xðú»
		/// </summary>
		public WroteResCollection()
		{
			// 
			// TODO: RXgN^ WbNð±±ÉÇÁµÄ­¾³¢B
			//
			totalSize = 0;
		}

		/// <summary>
		/// wèµ½resðRNVÉÇÁ
		/// </summary>
		/// <param name="res"></param>
		/// <returns></returns>
		public int Add(WroteRes res)
		{
			totalSize += res.Length;
			return List.Add(res);
		}

		/// <summary>
		/// WroteResRNVðRNVÉÇÁ
		/// </summary>
		public void AddRange(WroteResCollection resCollection)
		{
			foreach (WroteRes r in resCollection)
				totalSize += r.Length;
			InnerList.AddRange(resCollection);
		}

		/// <summary>
		/// ·×ÄÌvfðRNV©çí
		/// </summary>
		public new void Clear()
		{
			totalSize = 0;
			List.Clear();
		}
	}
}
