void AddCollection (ICollection <T> collection)
{
int collectionCount = collection.Count;
+ if (collectionCount == 0)
+ return;
+
GrowIfNeeded (collectionCount);
collection.CopyTo (_items, _size);
_size += collectionCount;
}
+
void AddEnumerable (IEnumerable <T> enumerable)
{
foreach (T t in enumerable)
public bool Contains (T item)
{
- return Array.IndexOf<T>(_items, item) != -1;
+ return Array.IndexOf<T>(_items, item, 0, _size) != -1;
}
public List <TOutput> ConvertAll <TOutput> (Converter <T, TOutput> converter)
int i = GetIndex(0, _size, match);
return (i != -1) ? _items [i] : default (T);
}
- void CheckMatch (Predicate <T> match)
+
+ static void CheckMatch (Predicate <T> match)
{
if (match == null)
throw new ArgumentNullException ("match");
public List <T> FindAll (Predicate <T> match)
{
- this.CheckMatch (match);
+ CheckMatch (match);
if (this._size <= 0x10000) // <= 8 * 1024 * 8 (8k in stack)
return this.FindAllStackBits (match);
else
Array.Copy (_items, start, _items, start + delta, _size - start);
_size += delta;
+
+ if (delta < 0)
+ Array.Clear (_items, _size, -delta);
}
void CheckIndex (int index)
if (!match(_items[j]))
_items[i++] = _items[j];
}
+ if (j - i > 0)
+ Array.Clear (_items, i, j - i);
_size = i;
return (j - i);
if (index < 0 || (uint)index >= (uint)_size)
throw new ArgumentOutOfRangeException("index");
Shift (index, -1);
+ Array.Clear (_items, _size, 1);
_version++;
}