Beispiel #1
0
 public static CList <V> Synchronized <V>(CList <V> list)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     return(new SyncList <V>(list));
 }
Beispiel #2
0
        /// <summary>源中创建的一个元素范围的浅表副本</summary>
        /// <returns>一个元素范围的浅表副本</returns>
        /// <param name="count">元素范围数量</param>
        /// <param name="index">从零开始ide多赢,指定范围的开始</param>
        /// <exception cref="System.ArgumentOutOfRangeException">index 小于 0. 或者count 小于 0.</exception>
        /// <exception cref="System.ArgumentException">index和count不代表列表中的元素的有效范围</exception>
        public new CList <T> GetRange(int index, int count)
        {
            CList <T> list;

            lock (this.list)
            {
                list = new CList <T>(this.list.GetRange(index, count));
            }

            return(list);
        }
Beispiel #3
0
        /// <summary>获取指定Predicate定义的条件相匹配的所有元素。</summary>
        /// <returns>如果遭到元素,返回指定Predicate定义的条件相匹配的所有元素列表,否则返回一个空列表。</see>.</returns>
        /// <param name="match">定义元素的条件来搜索的委托</param>
        /// <exception cref="System.ArgumentNullException">match 为 null.</exception>
        public new CList <T> FindAll(Predicate <T> match)
        {
            CList <T> temp;

            lock (this.list)
            {
                temp = new CList <T>(this.list.FindAll(match));
            }

            return(temp);
        }
Beispiel #4
0
        /// <summary>
        /// 转换当前 <see cref="System.Collections.Generic.List&lt;T&gt;"></see> 的元素到另外的类型,并返回包含转换后的元素列表。
        /// </summary>
        /// <returns>一个<see cref="System.Collections.Generic.List&lt;T&gt;"></see>集合,包含当前集合转换后的元素。</returns>
        /// <param name="converter">每个元素从一种类型到另一种类型的转换委托</param>
        /// <exception cref="System.ArgumentNullException">converter 为 null.</exception>
        public new CList <TOutput> ConvertAll <TOutput>(Converter <T, TOutput> converter)
        {
            CList <TOutput> list;

            lock (this.list)
            {
                list = new CList <TOutput>(this.list.ConvertAll(converter));
            }

            return(list);
        }
Beispiel #5
0
        /// <summary>返回一个<see cref="System.Collections.ArrayList"></see>对象,它的元素被复制为指定的值.</summary>
        /// <returns>一个有指定元素数量的 <see cref="System.Collections.ArrayList"></see>对象,它所有值被复制为指定的值。</returns>
        /// <param name="value">要复制的对象在新的ArrayList重复多次。该值可以为null。 </param>
        /// <param name="count">值被复制的次数</param>
        /// <exception cref="System.ArgumentOutOfRangeException">count 小于0. </exception>
        /// <typeparam name="V">列表中的元素的类型</typeparam>
        public static CList <V> Repeat <V>(V value, int count)
        {
            if (count < 0)
            {
                throw new ArgumentException("count", "Non-negative number required.");
            }

            CList <V> list = new CList <V>(count);

            for (int index = 0; index < count; index++)
            {
                list.Add(value);
            }

            return(list);
        }
Beispiel #6
0
 /// <summary>
 /// Dispose(bool disposing) executes in two distinct scenarios.
 /// If disposing equals true, the method has been called directly
 /// or indirectly by a user's code. Managed and unmanaged resources
 /// can be disposed.
 /// If disposing equals false, the method has been called by the
 /// runtime from inside the finalizer and you should not reference
 /// other objects. Only unmanaged resources can be disposed.
 /// </summary>
 /// <param name="disposing">if set to <see langword="true"/> [disposing].</param>
 private void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             // 释放托管资源
             if (list != null)
             {
                 list = null;
             }
             GC.SuppressFinalize(this);
         }
         disposed = true;
     }
 }
 /// <summary>
 /// 初始化OrderedDictionary类的新实例
 /// </summary>
 /// <param name="capacity">字典元素容量</param>
 /// <param name="comparer">比较器对象</param>
 public OrderedDictionary(int capacity, IEqualityComparer <TKey> comparer)
 {
     dictionary = new CDictionary <TKey, TValue>(capacity, comparer);
     list       = new CList <KeyValuePair <TKey, TValue> >();
 }
 /// <summary>
 /// 初始化OrderedDictionary类的新实例
 /// </summary>
 /// <param name="dictionary">字典表.</param>
 /// <param name="comparer">比较器对象</param>
 public OrderedDictionary(IDictionary <TKey, TValue> dictionary, IEqualityComparer <TKey> comparer)
 {
     this.dictionary = new CDictionary <TKey, TValue>(dictionary, comparer);
     list            = new CList <KeyValuePair <TKey, TValue> >();
 }
 /// <summary>
 /// 初始化OrderedDictionary类的新实例
 /// </summary>
 /// <param name="capacity">字典元素容量</param>
 public OrderedDictionary(int capacity)
 {
     dictionary = new CDictionary <TKey, TValue>(capacity);
     list       = new CList <KeyValuePair <TKey, TValue> >();
 }
 /// <summary>
 /// 初始化OrderedDictionary类的新实例
 /// </summary>
 /// <param name="dictionary">字典对象</param>
 public OrderedDictionary(IDictionary <TKey, TValue> dictionary)
 {
     this.dictionary = new CDictionary <TKey, TValue>(dictionary);
     list            = new CList <KeyValuePair <TKey, TValue> >();
 }
 /// <summary>
 /// 初始化OrderedDictionary类的新实例
 /// </summary>
 /// <summary>初始化OrderedDictionary类的新实例,实例为空并具有默认的初始容量,使用默认的相等比较器等。</summary>
 public OrderedDictionary()
 {
     dictionary = new CDictionary <TKey, TValue>();
     list       = new CList <KeyValuePair <TKey, TValue> >();
 }
Beispiel #12
0
 /// <summary>
 /// 初始化一个同步列表对象实例
 /// </summary>
 /// <param name="list">The list.</param>
 public SyncList(CList <T> list)
 {
     this.list = list;
 }
Beispiel #13
0
 /// <summary>
 /// 初始化一个OrderedDictionaryEnumerator对象实例
 /// </summary>
 /// <param name="list">列表</param>
 internal OrderedDictionaryEnumerator(CList <KeyValuePair <TKey, TValue> > list)
 {
     this.index = -1;
     this.list  = list;
 }