无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(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最新版的評論 (共 條)

分享到微博請遵守國家法律
阳东县| 全椒县| 苏尼特右旗| 临泉县| 尚义县| 河东区| 乌鲁木齐县| 布拖县| 兴义市| 房山区| 高邮市| 凤城市| 淄博市| 高雄县| 西宁市| 隆化县| 拜城县| 张掖市| 贵州省| 宝坻区| 海原县| 龙胜| 南部县| 高陵县| 隆化县| 德州市| 东辽县| 宁陕县| 额敏县| 湖北省| 磴口县| 聂拉木县| 新竹县| 济源市| 崇礼县| 遂昌县| 灵台县| 叶城县| 砀山县| 当涂县| 德昌县|