-
Notifications
You must be signed in to change notification settings - Fork 0
/
List.cs
35 lines (30 loc) · 886 Bytes
/
List.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Prototype
{
public class List<T>
{
private SizableArray<T> _payload = new (0, 0);
public void Add(T item)
{
if (_payload.Count == _payload.Capacity)
{
// need more room
var newCap = Math.Max(_payload.Capacity * 2, 4);
SizableArray<T>.Resize(ref _payload, newCap, _payload.Count);
}
_ = SizableArray<T>.IncreaseCount(ref _payload);
_payload[_payload.Count - 1] = item;
}
public T this[int index]
{
get => _payload[index];
set => _payload[index] = value;
}
public void Clear() => _payload.Clear();
public int Count => _payload.Count;
}
}