C#学习追根溯源之集合方法集

  1. System.Collections命名空间中的枚举器接口(IEnumerator)

    ***attention field :   object Current{get;}

    ***interface method: bool MoveNext()

    ***interface method: void Reset();

    using System;
    using System.Runtime.InteropServices;
    namespace System.Collections
    {
        // Summary:
        //     Supports a simple iteration over a nongeneric collection.
        [ComVisible(true)]
        [Guid("496B0ABF-CDEE-11d3-88E8-00902754C43A")]
        public interface IEnumerator
        {
            // Summary:
            //     Gets the current element in the collection.
            //
            // Returns:
            //     The current element in the collection.
            //
            // Exceptions:
            //   System.InvalidOperationException:
            //     The enumerator is positioned before the first element of the collection or
            //     after the last element.
            object Current { get; }

    // Summary:
            //     Advances the enumerator to the next element of the collection.
            //
            // Returns:
            //     true if the enumerator was successfully advanced to the next element; false
            //     if the enumerator has passed the end of the collection.
            //
            // Exceptions:
            //   System.InvalidOperationException:
            //     The collection was modified after the enumerator was created.
            bool MoveNext();
            //
            // Summary:
            //     Sets the enumerator to its initial position, which is before the first element
            //     in the collection.
            //
            // Exceptions:
            //   System.InvalidOperationException:
            //     The collection was modified after the enumerator was created.
            void Reset();
        }
    }

2.System.Collections命名空间中的可枚举类型接口(IEnumerable)

***interface method: GetEnumerator()

using System.Runtime.InteropServices;
namespace System.Collections
{
    // Summary:
    //     Exposes the enumerator, which supports a simple iteration over a non-generic
    //     collection.
    [ComVisible(true)]
    [Guid("496B0ABE-CDEE-11d3-88E8-00902754C43A")]
    public interface IEnumerable
    {
        // Summary:
        //     Returns an enumerator that iterates through a collection.
        //
        // Returns:
        //     An System.Collections.IEnumerator object that can be used to iterate through
        //     the collection.
        [DispId(-4)]
        IEnumerator GetEnumerator();
    }
}

3.System.Collections命名空间中的集合接口(ICollection)

***field: int Count{get;}

***field: bool isSynchronized{get;}

***field: object SyncRoot{get;}//同步根

***inteface method: CopyTo(Array array,int index);//attention there is a argument:Array

using System;
using System.Runtime.InteropServices;

namespace System.Collections
{
    // Summary:
    //     Defines size, enumerators, and synchronization methods for all nongeneric
    //     collections.
    [ComVisible(true)]
    public interface ICollection : IEnumerable
    {
        // Summary:
        //     Gets the number of elements contained in the System.Collections.ICollection.
        //
        // Returns:
        //     The number of elements contained in the System.Collections.ICollection.
        int Count { get; }
        //
        // Summary:
        //     Gets a value indicating whether access to the System.Collections.ICollection
        //     is synchronized (thread safe).
        //
        // Returns:
        //     true if access to the System.Collections.ICollection is synchronized (thread
        //     safe); otherwise, false.
        bool IsSynchronized { get; }
        //
        // Summary:
        //     Gets an object that can be used to synchronize access to the System.Collections.ICollection.
        //
        // Returns:
        //     An object that can be used to synchronize access to the System.Collections.ICollection.
        object SyncRoot { get; }

// Summary:
        //     Copies the elements of the System.Collections.ICollection to an System.Array,
        //     starting at a particular System.Array index.
        //
        // Parameters:
        //   array:
        //     The one-dimensional System.Array that is the destination of the elements
        //     copied from System.Collections.ICollection. The System.Array must have zero-based
        //     indexing.
        //
        //   index:
        //     The zero-based index in array at which copying begins.
        //
        // Exceptions:
        //   System.ArgumentNullException:
        //     array is null.
        //
        //   System.ArgumentOutOfRangeException:
        //     index is less than zero.
        //
        //   System.ArgumentException:
        //     array is multidimensional.-or- The number of elements in the source System.Collections.ICollection
        //     is greater than the available space from index to the end of the destination
        //     array.
        //
        //   System.ArgumentException:
        //     The type of the source System.Collections.ICollection cannot be cast automatically
        //     to the type of the destination array.
        void CopyTo(Array array, int index);
    }
}

4.System.Collections命名空间中的列表接口(IList)

***field: bool IsFixedSize{get;}

***field: bool IsReadOnly{get;}

***indexer: object this[int index]{get;set;}//索引器
(indexer)是这样一个成员:它支持按照索引数组的方法来索引对象。索引器的声明与属性类似,不同的是该成员的名称是this,后跟一个位于定界符[和]之间的参数列表。在索引器的访问器中可以使用这些参数。与属性类似,索引器可以是读写、只读和只写的,并且索引器的访问器可以是虚的。

***interface method: int Add(object value);

***interface method: void Clear();

***interface method: bool Contains(object value);

***interface method: int IndexOf(object value);

***interface method:void Insert(int index,object value);

***interface method:void Remove(object value);

***interface method: void RemoveAt(int index);

using System;
using System.Reflection;
using System.Runtime.InteropServices;

namespace System.Collections
{
    // Summary:
    //     Represents a non-generic collection of objects that can be individually accessed
    //     by index.
    [ComVisible(true)]
    public interface IList : ICollection, IEnumerable
    {
        // Summary:
        //     Gets a value indicating whether the System.Collections.IList has a fixed
        //     size.
        //
        // Returns:
        //     true if the System.Collections.IList has a fixed size; otherwise, false.
        bool IsFixedSize { get; }
        //
        // Summary:
        //     Gets a value indicating whether the System.Collections.IList is read-only.
        //
        // Returns:
        //     true if the System.Collections.IList is read-only; otherwise, false.
        bool IsReadOnly { get; }

// Summary:
        //     Gets or sets the element at the specified index.
        //
        // Parameters:
        //   index:
        //     The zero-based index of the element to get or set.
        //
        // Returns:
        //     The element at the specified index.
        //
        // Exceptions:
        //   System.ArgumentOutOfRangeException:
        //     index is not a valid index in the System.Collections.IList.
        //
        //   System.NotSupportedException:
        //     The property is set and the System.Collections.IList is read-only.
        object this[int index] { get; set; }

// Summary:
        //     Adds an item to the System.Collections.IList.
        //
        // Parameters:
        //   value:
        //     The object to add to the System.Collections.IList.
        //
        // Returns:
        //     The position into which the new element was inserted, or -1 to indicate that
        //     the item was not inserted into the collection,
        //
        // Exceptions:
        //   System.NotSupportedException:
        //     The System.Collections.IList is read-only.-or- The System.Collections.IList
        //     has a fixed size.
        int Add(object value);
        //
        // Summary:
        //     Removes all items from the System.Collections.IList.
        //
        // Exceptions:
        //   System.NotSupportedException:
        //     The System.Collections.IList is read-only.
        void Clear();
        //
        // Summary:
        //     Determines whether the System.Collections.IList contains a specific value.
        //
        // Parameters:
        //   value:
        //     The object to locate in the System.Collections.IList.
        //
        // Returns:
        //     true if the System.Object is found in the System.Collections.IList; otherwise,
        //     false.
        bool Contains(object value);
        //
        // Summary:
        //     Determines the index of a specific item in the System.Collections.IList.
        //
        // Parameters:
        //   value:
        //     The object to locate in the System.Collections.IList.
        //
        // Returns:
        //     The index of value if found in the list; otherwise, -1.
        int IndexOf(object value);
        //
        // Summary:
        //     Inserts an item to the System.Collections.IList at the specified index.
        //
        // Parameters:
        //   index:
        //     The zero-based index at which value should be inserted.
        //
        //   value:
        //     The object to insert into the System.Collections.IList.
        //
        // Exceptions:
        //   System.ArgumentOutOfRangeException:
        //     index is not a valid index in the System.Collections.IList.
        //
        //   System.NotSupportedException:
        //     The System.Collections.IList is read-only.-or- The System.Collections.IList
        //     has a fixed size.
        //
        //   System.NullReferenceException:
        //     value is null reference in the System.Collections.IList.
        void Insert(int index, object value);
        //
        // Summary:
        //     Removes the first occurrence of a specific object from the System.Collections.IList.
        //
        // Parameters:
        //   value:
        //     The object to remove from the System.Collections.IList.
        //
        // Exceptions:
        //   System.NotSupportedException:
        //     The System.Collections.IList is read-only.-or- The System.Collections.IList
        //     has a fixed size.
        void Remove(object value);
        //
        // Summary:
        //     Removes the System.Collections.IList item at the specified index.
        //
        // Parameters:
        //   index:
        //     The zero-based index of the item to remove.
        //
        // Exceptions:
        //   System.ArgumentOutOfRangeException:
        //     index is not a valid index in the System.Collections.IList.
        //
        //   System.NotSupportedException:
        //     The System.Collections.IList is read-only.-or- The System.Collections.IList
        //     has a fixed size.
        void RemoveAt(int index);
    }
}

时间: 2024-11-14 10:07:29

C#学习追根溯源之集合方法集的相关文章

Java集合框架学习笔记之集合与Collection API

一.CollectionAPI 集合是一系列对象的聚集(Collection).集合在程序设计中是一种重要的数据接口.Java中提供了有关集合的类库称为CollectionAPI. 集合实际上是用一个对象代表一组对象,在集合中的每个对象称为一个元素.在集合中的各个元素的具体类型可以不同,但一般说来,它们都是由相同的类派生出来的(而这一点并不难做到,因为Java中的所有类都是Object的子类).在从集合中检索出各个元素是,常常要根据其具体类型不同而进行相应的强制类型转换. Collection

【Python学习笔记】集合

概述 集合的一般操作 内建函数进行标准操作集合 数学运算符进行标准操作集合 集合的应用 概述 python的集合(set)是无序不重复元素集,是一种容器.集合(set)中的元素必须是不可变对象,即可用被哈希,这和字典的键是一样的,所以列表.字典等可变对象不可作为set的元素.集合不提供索引或切片操作,即对象不存在相关的键值.python中的集合分为两种:set是可变的集合,frozenset是不可变的集合. 集合的创建使用关键字set或frozenset, 参数可以是列表.字符串或元组等不可变对

Guava学习笔记: guava集合之Multiset

Guava学习笔记: guava集合之Multiset Multiset是什么? Multiset看似是一个Set,但是实质上它不是一个Set,它没有继承Set接口,它继承的是Collection<E>接口,你可以向Multiset中添加重复的元素,Multiset会对添加的元素做一个计数. 它本质上是一个Set加一个元素计数器. Multiset使用示例: package cn.outofmemory.guava.collection; import com.google.common.ba

计算机算法学习(1) - 不相交集合数据结构

不相交集合 故名思意就是一种含有多个不相交集合的数据结构.典型的应用是确定无向图中连通子图的个数.其基本操作包括: Make-Set(x):建立一个新的集合,集合的成员是x: Union(x,y): 将包含x和y的集合合并为一个集合: Find-Set(x): 返回指向包含x的集合的指针: 下面是一个例子,(a)是一个无向图,(b)是使用不相交集合来找连通子图的个数.做法是初始为各个顶点为一个集合,然后遍历各个边,把边的端点的集合进行合并,当处理完所有的边,能连通的顶点就在一个集合里了,这样就生

[转]在线学习java资料集合

原文链接: fromdev 翻译: ImportNew.com- 赖 信涛译文链接: http://www.importnew.com/11910.html[ 转载请保留原文出处.译者和译文链接.] 本文由 ImportNew - 赖 信涛 翻译自 fromdev.欢迎加入Java小组.转载请参见文章末尾的要求. 你想学习Java吗?来对地方了!这篇文章将会介绍很多高质量的免费资源,包括网页.论坛.电子书和速查表. Java是一种面向对象的编程语言,拥有独立.多线程.安全.动态和健壮的特点.归功

Hadoop学习笔记_4_实施Hadoop集群 --伪分布式安装

实施Hadoop集群 --伪分布式安装 准备与配置安装环境 安装虚拟机和linux,虚拟机推荐使用vmware,PC可以使用workstation,服务器可以使用ESXi,在管理上比较方便.ESXi还可以通过拷贝镜像文件复制虚拟机,复制后自动修改网卡号和ip,非常快捷.如果只是实验用途,硬盘大约预留20-30G空间. 以Centos为例,分区可以选择默认[如果想要手动分区,请参考博客:http://blog.csdn.net/zjf280441589/article/details/175485

Heartbeat学习笔记--HA高可用集群实现

一.部署环境: 服务器版本:CentOS6.5 双主热备模式: VIP:192.168.3.30(MASTER上) VIP:192.168.3.32(BACKUP上) 主机网络参数: 接口 MASTER BACKUP 说明 eth1 192.168.3.23 192.168.3.24 内网管理IP eth2 192.168.5.23 192.168.5.24 心跳线 eth3 192.168.2.23 192.168.2.24 外网(临时下载文件用) 网络拓扑: 二.需求分析: 通过Heartb

swift 学习资源 大集合

今天看到了一个swift的学习网站,里面收集了很多学习资源 Swift 介绍 Swift 介绍 来自 Apple 官方 Swift 简介 (@peng_gong) 一篇不错的中文简介 [译] Swift 首席架构师 Chris Lattner 简介(黄利民) Swift 背后的男人,他的个人主页. Swift 观点 如何评价 Swift 语言?(@知乎) 已有近 5000 人关注该问题! [译] Rust 创始人 Graydon Hoare 对 Swift 的看法 (@CSDN) 无废话 Swi

Hadoop学习笔记_8_实施Hadoop集群 --分布式安装Hadoop

实施Hadoop集群 --分布式安装Hadoop 说明: 以Ubuntu配置为例,其中与CentOS不同之处会给出详细说明 现有三台服务器:其IP与主机名对应关系为: 192.168.139.129 master #NameNode/JobTrackerr结点 192.168.139.132 slave01 #DataNode/TaskTracker结点 192.168.139.137 slave02 #DataNode/TaskTracker结点 一.配置ssh实现Hadoop节点间用户的无密