Class ArrayList<T>
A self expanding array implementation.
Inherited Members
Namespace: Advanced.Algorithms.DataStructures.Foundation
Assembly: Advanced.Algorithms.dll
Syntax
public class ArrayList<T> : IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | The datatype of this ArrayList. |
Constructors
ArrayList(IEnumerable<T>)
Time complexity: O(1) if initial is empty otherwise O(n).
Declaration
public ArrayList(IEnumerable<T> initial)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | initial | Initial values if any. |
ArrayList(Int32, IEnumerable<T>)
Time complexity: O(1) if initial is empty otherwise O(n).
Declaration
public ArrayList(int initalArraySize = 2, IEnumerable<T> initial = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | initalArraySize | The initial array size. |
IEnumerable<T> | initial | Initial values if any. |
Properties
Item[Int32]
Indexed access to array. Time complexity: O(1).
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index to write or read. |
Property Value
Type | Description |
---|---|
T |
Length
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
Add(T)
Add a new item to this array list. Time complexity: O(1) amortized.
Declaration
public void Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Clear()
Clears the array. Time complexity: O(1).
Declaration
public void Clear()
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> |
InsertAt(Int32, T)
Declaration
public void InsertAt(int index, T item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | |
T | item |
RemoveAt(Int32)
Remove the item at given index. Time complexity: O(1) amortized.
Declaration
public void RemoveAt(int i)
Parameters
Type | Name | Description |
---|---|---|
Int32 | i | The index to remove at. |
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |