最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

C#編程-第二季-面向?qū)ο?宇宙最簡單2021最新版

2023-08-10 15:21 作者:霧隱半山  | 我要投稿

using System;


class MyList<T>

{

??private T[] items;

??private int count;


??public MyList()

??{

????items = new T[4];

????count = 0;

??}


??public int Capacity => items.Length;


??public int Count => count;


??public T this[int index]

??{

????get

????{

??????if (index < 0 || index >= count)

??????{

????????throw new IndexOutOfRangeException();

??????}

??????return items[index];

????}

????set

????{

??????if (index < 0 || index >= count)

??????{

????????throw new IndexOutOfRangeException();

??????}

??????items[index] = value;

????}

??}


??public void Add(T item)

??{

????if (count == items.Length)

????{

??????ResizeArray();

????}

????items[count] = item;

????count++;

??}


??public void Insert(int index, T item)

??{

????if (index < 0 || index > count)

????{

??????throw new IndexOutOfRangeException();

????}

????if (count == items.Length)

????{

??????ResizeArray();

????}

????for (int i = count; i > index; i--)

????{

??????items[i] = items[i - 1];

????}

????items[index] = item;

????count++;

??}


??public void RemoveAt(int index)

??{

????if (index < 0 || index >= count)

????{

??????throw new IndexOutOfRangeException();

????}

????for (int i = index; i < count - 1; i++)

????{

??????items[i] = items[i + 1];

????}

????count--;

????items[count] = default(T);

??}


??public int IndexOf(T item)

??{

????for (int i = 0; i < count; i++)

????{

??????if (items[i].Equals(item))

??????{

????????return i;

??????}

????}

????return -1;

??}


??public int LastIndexOf(T item)

??{

????for (int i = count - 1; i >= 0; i--)

????{

??????if (items[i].Equals(item))

??????{

????????return i;

??????}

????}

????return -1;

??}


??public void Sort()

??{

????Array.Sort(items, 0, count);

??}


??private void ResizeArray()

??{

????int newCapacity = items.Length * 2;

????T[] newArray = new T[newCapacity];

????Array.Copy(items, newArray, count);

????items = newArray;

??}

}


C#編程-第二季-面向?qū)ο?宇宙最簡單2021最新版的評論 (共 條)

分享到微博請遵守國家法律
犍为县| 通辽市| 菏泽市| 蓝田县| 徐州市| 大余县| 昂仁县| 石家庄市| 林周县| 壶关县| 柳州市| 阿拉善左旗| 顺昌县| 筠连县| 莎车县| 巧家县| 南投县| 汝州市| 河池市| 巧家县| 商城县| 五莲县| 临清市| 巩义市| 福鼎市| 延寿县| 林甸县| 邯郸市| 上饶县| 乌拉特中旗| 津南区| 长岛县| 响水县| 临城县| 崇明县| 新巴尔虎左旗| 固始县| 府谷县| 合江县| 东山县| 牙克石市|