context: // **********************************************************************
  //
  // Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
  //
  // This copy of Ice is licensed to you under the terms described in the
  // ICE_LICENSE file included in this distribution.
  //
  // **********************************************************************
  
  using System;
  using System.Collections.Generic;
  
  namespace IceInternal
  {
  #if !SILVERLIGHT
      [Serializable]
  #endif
      public abstract class CollectionBase<T> : System.Collections.IList
      {
          protected List<T> list_;
  
          public CollectionBase()
          {
              list_ = new List<T>();
          }
  
          public CollectionBase(int capacity)
          {
              list_ = new List<T>(capacity);
          }
  
          public CollectionBase(T[] a)
          {
              if(a == null)
              {
                  throw new ArgumentNullException("a", "Cannot construct collection from null array");
              }
  
              list_ = new List<T>(a.Length);
              list_.AddRange(a);
          }
  
          public CollectionBase(IEnumerable<T> l)
          {
              if(l == null)
              {
                  throw new ArgumentNullException("l", "Cannot construct collection from null collection");
              }
  
              list_ = new List<T>();
              list_.AddRange(l);
          }
  
          public static implicit operator List<T>(CollectionBase<T> l)
          {
              return l.list_;
          }
  
  
          public void CopyTo(T[] a__)
          {
              list_.CopyTo(a__);
          }
  
          public void CopyTo(T[] a__, int i__)
          {
              list_.CopyTo(a__, i__);
          }
  
          public void CopyTo(int i__, T[] a__, int ai__, int _c_)
          {
              list_.CopyTo(i__, a__, ai__, _c_);
          }
  
          public T[] ToArray()
          {
              return list_.ToArray();
          }
  
          public virtual void TrimToSize()
          {
              list_.TrimExcess();
          }
  
          public virtual void Sort()
          {
              list_.Sort();
          }
  
          public virtual void Sort(System.Collections.IComparer comparer)
          {
              list_.Sort(new Comparer(comparer));
          }
  
          public virtual void Sort(int index, int count, System.Collections.IComparer comparer)
          {
              list_.Sort(index, count, new Comparer(comparer));
          }
  
          public virtual void Reverse()
          {
              list_.Reverse();
          }
  
          public virtual void Reverse(int index, int count)
          {
              list_.Reverse(index, count);
          }
  
          public virtual int BinarySearch(T value)
          {
              return list_.BinarySearch(value);
          }
  
          public virtual int BinarySearch(T value, System.Collections.IComparer comparer)
          {
              return list_.BinarySearch(value, new Comparer(comparer));
          }
  
          public virtual int BinarySearch(int index, int count, T value, System.Collections.IComparer comparer)
          {
              return list_.BinarySearch(index, count, value, new Comparer(comparer));
          }
  
          public virtual void InsertRange(int index, CollectionBase<T> c)
          {
              list_.InsertRange(index, c.list_);
          }
  
          public virtual void InsertRange(int index, T[] c)
          {
              list_.InsertRange(index, c);
          }
  
          public virtual void RemoveRange(int index, int count)
          {
              list_.RemoveRange(index, count);
          }
  
          public virtual void SetRange(int index, CollectionBase<T> c)
          {
              if(c == null)
              {
                  throw new ArgumentNullException("c", "Collection must not be null for SetRange()");
              }
              if(index < 0 || index + c.Count > list_.Count)
              {
                  throw new ArgumentOutOfRangeException("index", "Index out of range");
              }
              for(int i = index; i < list_.Count; ++i)
              {
                  list_[i] = c[i - index];
              }
          }
  
          public virtual void SetRange(int index, T[] c)
          {
              if(c == null)
              {
                  throw new ArgumentNullException("c", "Collection must not be null for SetRange()");
              }
              if(index < 0 || index + c.Length > list_.Count)
              {
                  throw new ArgumentOutOfRangeException("index", "Index out of range");
              }
              for(int i = index; i < list_.Count; ++i)
              {
                  list_[i] = c[i - index];
              }
          }
  
          public virtual int LastIndexOf(T value)
          {
              return list_.LastIndexOf(value);
          }
  
          public virtual int LastIndexOf(T value, int startIndex)
          {
              return list_.LastIndexOf(value, startIndex);
          }
  
          public virtual int LastIndexOf(T value, int startIndex, int count)
          {
              return list_.LastIndexOf(value, startIndex, count);
          }
  
          public void AddRange(CollectionBase<T> s__)
          {
              list_.AddRange(s__.list_);
          }
  
          public void AddRange(T[] a__)
          {
              list_.AddRange(a__);
          }
  
          public int Capacity
          {
              get
              {
                  return list_.Capacity;
              }
  
              set
              {
                  list_.Capacity = value;
              }
          }
  
          public int Count
          {
              get
              {
                  return list_.Count;
              }
          }
  
          System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
          {
              return list_.GetEnumerator();
          }
  
          public IEnumerator<T> GetEnumerator()
          {
              return list_.GetEnumerator();
          }
  
          public void RemoveAt(int index)
          {
              list_.RemoveAt(index);
          }
  
          public int Add(T value)
          {
              list_.Add(value);
              return list_.Count - 1;
          }
  
          public void Clear()
          {
              list_.Clear();
          }
  
          public bool IsFixedSize
          {
              get
              {
                  return false;
              }
          }
  
          public bool IsReadOnly
          {
              get
              {
                  return false;
              }
          }
  
          public int IndexOf(T value)
          {
              return list_.IndexOf(value);
          }
  
          public void Insert(int index, T value)
          {
              list_.Insert(index, value);
          }
  
          public void Remove(T value)
          {
              list_.Remove(value);
          }
  
          public bool Contains(T value)
          {
              return list_.Contains(value);
          }
  
          public bool IsSynchronized
          {
              get
              {
                  return false;
              }
          }
  
          public object SyncRoot
          {
              get
              {
                  return this;
              }
          }
  
          public T this[int index]
          {
              get
              {
                  return list_[index];
              }
              set
              {
                  list_[index] = value;
              }
          }
  
          public override int GetHashCode()
          {
              int h = 5381;
  
gt:             for(int i = 0; i < Count; ++i)