mirror of
https://github.com/ZuneDev/Xune.git
synced 2026-07-27 13:13:10 -07:00
Simplified usages
This commit is contained in:
@@ -14,7 +14,7 @@ public class Vector<A> : IVector
|
||||
private A[] _items;
|
||||
private int _size;
|
||||
|
||||
public Vector() => this._items = Vector<A>.s_emptyArray;
|
||||
public Vector() => this._items = s_emptyArray;
|
||||
|
||||
public Vector(int capacity) => this._items = new A[capacity];
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Vector<A> : IVector
|
||||
{
|
||||
int count = collection1.Count;
|
||||
this._items = new A[count];
|
||||
collection1.CopyTo((Array)this._items, 0);
|
||||
collection1.CopyTo(_items, 0);
|
||||
this._size = count;
|
||||
}
|
||||
else
|
||||
@@ -56,11 +56,11 @@ public class Vector<A> : IVector
|
||||
{
|
||||
A[] aArray = new A[value];
|
||||
if (this._size > 0)
|
||||
Array.Copy((Array)this._items, 0, (Array)aArray, 0, this._size);
|
||||
Array.Copy(_items, 0, aArray, 0, this._size);
|
||||
this._items = aArray;
|
||||
}
|
||||
else
|
||||
this._items = Vector<A>.s_emptyArray;
|
||||
this._items = s_emptyArray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class Vector<A> : IVector
|
||||
set => this._items[index] = value;
|
||||
}
|
||||
|
||||
object IVector.this[int index] => (object)this[index];
|
||||
object IVector.this[int index] => this[index];
|
||||
|
||||
public void Add(A item)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ public class Vector<A> : IVector
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Array.Clear((Array)this._items, 0, this._size);
|
||||
Array.Clear(_items, 0, this._size);
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ public class Vector<A> : IVector
|
||||
return;
|
||||
try
|
||||
{
|
||||
Array.Copy((Array)this._items, 0, array, index, this._size);
|
||||
Array.Copy(_items, 0, array, index, this._size);
|
||||
}
|
||||
catch (ArrayTypeMismatchException ex)
|
||||
{
|
||||
throw new ArgumentException((string)null);
|
||||
throw new ArgumentException(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class Vector<A> : IVector
|
||||
if (this._size == this._items.Length)
|
||||
this.EnsureCapacity(this._size + 1);
|
||||
if (index < this._size)
|
||||
Array.Copy((Array)this._items, index, (Array)this._items, index + 1, this._size - index);
|
||||
Array.Copy(_items, index, _items, index + 1, this._size - index);
|
||||
this._items[index] = item;
|
||||
++this._size;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class Vector<A> : IVector
|
||||
{
|
||||
--this._size;
|
||||
if (index < this._size)
|
||||
Array.Copy((Array)this._items, index + 1, (Array)this._items, index, this._size - index);
|
||||
Array.Copy(_items, index + 1, _items, index, this._size - index);
|
||||
this._items[this._size] = default(A);
|
||||
}
|
||||
|
||||
@@ -148,26 +148,26 @@ public class Vector<A> : IVector
|
||||
return;
|
||||
this._size -= count;
|
||||
if (index < this._size)
|
||||
Array.Copy((Array)this._items, index + count, (Array)this._items, index, this._size - index);
|
||||
Array.Clear((Array)this._items, this._size, count);
|
||||
Array.Copy(_items, index + count, _items, index, this._size - index);
|
||||
Array.Clear(_items, this._size, count);
|
||||
}
|
||||
|
||||
public void Sort() => this.Sort(0, this.Count, (IComparer)null);
|
||||
public void Sort() => this.Sort(0, this.Count, null);
|
||||
|
||||
public void Sort(IComparer comparer) => this.Sort(0, this.Count, comparer);
|
||||
|
||||
public void Sort(int index, int count, IComparer comparer) => Array.Sort((Array)this._items, index, count, comparer);
|
||||
public void Sort(int index, int count, IComparer comparer) => Array.Sort(_items, index, count, comparer);
|
||||
|
||||
public A[] ToArray()
|
||||
{
|
||||
A[] aArray = new A[this._size];
|
||||
Array.Copy((Array)this._items, 0, (Array)aArray, 0, this._size);
|
||||
Array.Copy(_items, 0, aArray, 0, this._size);
|
||||
return aArray;
|
||||
}
|
||||
|
||||
public void TrimExcess()
|
||||
{
|
||||
if (this._size >= (int)((double)this._items.Length * 0.9))
|
||||
if (this._size >= (int)(_items.Length * 0.9))
|
||||
return;
|
||||
this.Capacity = this._size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user