4 using System.Collections;
5 using System.Collections.Generic;
6 using System.Runtime.InteropServices;
8 namespace SiliconStudio.Core.Collections
19 public T
this[
int index]
21 get {
return Items[index]; }
30 this.Count = fastList.Count;
31 this.Items = fastList.Items;
36 this.Count = array.Length;
43 this.Items =
new T[capacity];
46 public void Add(T item)
48 if (this.Count == this.Items.Length)
49 this.EnsureCapacity(this.Count + 1);
50 this.Items[this.Count++] = item;
53 public void Insert(
int index, T item)
55 if (Count == Items.Length)
57 EnsureCapacity(Count + 1);
61 for (
int i = Count; i > index; --i)
63 Items[i] = Items[i - 1];
75 Array.Copy(Items, index + 1, Items, index, Count - index);
77 Items[Count] =
default(T);
87 if (this.Items.Length < newCapacity)
89 int newSize = this.Items.Length * 2;
90 if (newSize < newCapacity)
91 newSize = newCapacity;
93 var destinationArray =
new T[newSize];
94 Array.Copy(this.Items, 0, destinationArray, 0, this.Count);
95 this.Items = destinationArray;
101 return new Enumerator(Items, Count);
104 IEnumerator IEnumerable.GetEnumerator()
106 return new Enumerator(Items, Count);
111 return new Enumerator(Items, Count);
126 return IndexOf(item) >= 0;
131 return Array.IndexOf(Items, item, 0, Count);
134 #region Nested type: Enumerator
136 [StructLayout(LayoutKind.Sequential)]
137 public struct Enumerator : IEnumerator<T>, IDisposable, IEnumerator
144 internal Enumerator(T[] items,
int count)
149 current =
default(T);
160 current = items[index];
164 return MoveNextRare();
167 private bool MoveNextRare()
170 current =
default(T);
176 get {
return current; }
179 object IEnumerator.Current
181 get {
return Current; }
184 void IEnumerator.Reset()
187 current =
default(T);
FastListStruct(FastList< T > fastList)
void Insert(int index, T item)
FastListStruct(int capacity)
Similar to List{T}, with direct access to underlying array.
void EnsureCapacity(int newCapacity)
Enumerator GetEnumerator()
FastListStruct(T[] array)