Here are the examples of the csharp api class System.Collections.ArrayList.EnsureCapacity(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
9 Examples
0
1. Example
Project: referencesource
Source File: arraylist.cs
Source File: arraylist.cs
public virtual int Add(Object value) { Contract.Ensures(Contract.Result<int>() >= 0); if (_size == _items.Length) EnsureCapacity(_size + 1); _items[_size] = value; _version++; return _size++; }
0
2. Example
Project: referencesource
Source File: arraylist.cs
Source File: arraylist.cs
public virtual void Insert(int index, Object value) { // Note that insertions at the end are legal. if (index < 0 || index > _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_ArrayListInsert")); //Contract.Ensures(Count == Contract.OldValue(Count) + 1); Contract.EndContractBlock(); if (_size == _items.Length) EnsureCapacity(_size + 1); if (index < _size) { Array.Copy(_items, index, _items, index + 1, _size - index); } _items[index] = value; _size++; _version++; }
0
3. Example
Project: referencesource
Source File: arraylist.cs
Source File: arraylist.cs
public virtual void InsertRange(int index, ICollection c) { if (c==null) throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection")); if (index < 0 || index > _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index")); //Contract.Ensures(Count == Contract.OldValue(Count) + c.Count); Contract.EndContractBlock(); int count = c.Count; if (count > 0) { EnsureCapacity(_size + count); // shift existing items if (index < _size) { Array.Copy(_items, index, _items, index + count, _size - index); } Object[] itemsToInsert = new Object[count]; c.CopyTo(itemsToInsert, 0); itemsToInsert.CopyTo(_items, index); _size += count; _version++; } }
0
4. Example
Project: llilum
Source File: ArrayList.cs
Source File: ArrayList.cs
public virtual int Add( Object value ) { if(m_size == m_items.Length) { EnsureCapacity( m_size + 1 ); } m_items[m_size] = value; m_version++; return m_size++; }
0
5. Example
Project: llilum
Source File: ArrayList.cs
Source File: ArrayList.cs
public virtual void Insert( int index, Object value ) { // Note that insertions at the end are legal. if(index < 0 || index > m_size) { #if EXCEPTION_STRINGS throw new ArgumentOutOfRangeException( "index", Environment.GetResourceString( "ArgumentOutOfRange_ArrayListInsert" ) ); #else throw new ArgumentOutOfRangeException(); #endif } if(m_size == m_items.Length) EnsureCapacity( m_size + 1 ); if(index < m_size) { Array.Copy( m_items, index, m_items, index + 1, m_size - index ); } m_items[index] = value; m_size++; m_version++; }
0
6. Example
Project: SharpLang
Source File: ArrayList.cs
Source File: ArrayList.cs
public virtual int Add(Object value) { Contract.Ensures(Contract.Result<int>() >= 0); if (_size == _items.Length) EnsureCapacity(_size + 1); _items[_size] = value; _version++; return _size++; }
0
7. Example
Project: SharpLang
Source File: ArrayList.cs
Source File: ArrayList.cs
public virtual void Insert(int index, Object value) { // Note that insertions at the end are legal. if (index < 0 || index > _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_ArrayListInsert")); //Contract.Ensures(Count == Contract.OldValue(Count) + 1); Contract.EndContractBlock(); if (_size == _items.Length) EnsureCapacity(_size + 1); if (index < _size) { Array.Copy(_items, index, _items, index + 1, _size - index); } _items[index] = value; _size++; _version++; }
0
8. Example
Project: llilum
Source File: ArrayList.cs
Source File: ArrayList.cs
public virtual void InsertRange( int index, ICollection c ) { if(c == null) { #if EXCEPTION_STRINGS throw new ArgumentNullException( "c", Environment.GetResourceString( "ArgumentNull_Collection" ) ); #else throw new ArgumentNullException(); #endif } if(index < 0 || index > m_size) { #if EXCEPTION_STRINGS throw new ArgumentOutOfRangeException( "index", Environment.GetResourceString( "ArgumentOutOfRange_Index" ) ); #else throw new ArgumentOutOfRangeException(); #endif } int count = c.Count; if(count > 0) { EnsureCapacity( m_size + count ); // shift existing items if(index < m_size) { Array.Copy( m_items, index, m_items, index + count, m_size - index ); } Object[] itemsToInsert = new Object[count]; c.CopyTo( itemsToInsert, 0 ); itemsToInsert.CopyTo( m_items, index ); m_size += count; m_version++; } }
0
9. Example
Project: SharpLang
Source File: ArrayList.cs
Source File: ArrayList.cs
public virtual void InsertRange(int index, ICollection c) { if (c==null) throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection")); if (index < 0 || index > _size) throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index")); //Contract.Ensures(Count == Contract.OldValue(Count) + c.Count); Contract.EndContractBlock(); int count = c.Count; if (count > 0) { EnsureCapacity(_size + count); // shift existing items if (index < _size) { Array.Copy(_items, index, _items, index + count, _size - index); } Object[] itemsToInsert = new Object[count]; c.CopyTo(itemsToInsert, 0); itemsToInsert.CopyTo(_items, index); _size += count; _version++; } }