Table of Contents

Class InstructionCollection<T>

Namespace
ICSharpCode.Decompiler.IL
Assembly
ICSharpCode.Decompiler.dll
public sealed class InstructionCollection<T> : IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable where T : ILInstruction

Type Parameters

T
Inheritance
InstructionCollection<T>
Implements
Inherited Members

Constructors

InstructionCollection(ILInstruction, int)

public InstructionCollection(ILInstruction parentInstruction, int firstChildIndex)

Parameters

parentInstruction ILInstruction
firstChildIndex int

Properties

Count

public int Count { get; }

Property Value

int

this[int]

public T this[int index] { get; set; }

Parameters

index int

Property Value

T

Methods

Add(T)

public void Add(T value)

Parameters

value T

AddRange(IEnumerable<T>)

public void AddRange(IEnumerable<T> values)

Parameters

values IEnumerable<T>

Clear()

public void Clear()

Contains(T?)

Gets whether the item is in this collection.

public bool Contains(T? item)

Parameters

item T

Returns

bool

Remarks

This method searches the list. Usually it's more efficient to test item.Parent instead!

ElementAtOrDefault(int)

public T? ElementAtOrDefault(int index)

Parameters

index int

Returns

T

First()

public T First()

Returns

T

FirstOrDefault()

public T? FirstOrDefault()

Returns

T

GetEnumerator()

public InstructionCollection<T>.Enumerator GetEnumerator()

Returns

InstructionCollection<T>.Enumerator

IndexOf(T?)

Gets the index of the instruction in this collection. Returns -1 if the instruction does not exist in the collection.

public int IndexOf(T? item)

Parameters

item T

Returns

int

Remarks

Runs in O(1) if the item can be found using the Parent/ChildIndex properties. Otherwise, runs in O(N).

Insert(int, T)

public void Insert(int index, T item)

Parameters

index int
item T

Last()

public T Last()

Returns

T

LastOrDefault()

public T? LastOrDefault()

Returns

T

MoveElementToEnd(int)

public void MoveElementToEnd(int index)

Parameters

index int

MoveElementToEnd(T)

public void MoveElementToEnd(T item)

Parameters

item T

MoveElementToIndex(int, int)

public void MoveElementToIndex(int oldIndex, int newIndex)

Parameters

oldIndex int
newIndex int

MoveElementToIndex(T, int)

public void MoveElementToIndex(T item, int newIndex)

Parameters

item T
newIndex int

Remove(T)

public bool Remove(T item)

Parameters

item T

Returns

bool

RemoveAll(Predicate<T>)

Removes all elements for which the predicate returns true.

public int RemoveAll(Predicate<T> predicate)

Parameters

predicate Predicate<T>

Returns

int

Remarks

This method runs in O(N), which is more efficient than calling RemoveAt() in a loop. The collection may be in an invalid state during the invocation of the predicate.

RemoveAt(int)

public void RemoveAt(int index)

Parameters

index int

RemoveRange(int, int)

public void RemoveRange(int index, int count)

Parameters

index int
count int

ReplaceList(IEnumerable<T>)

Replaces all entries in the InstructionCollection with the newList.

public void ReplaceList(IEnumerable<T> newList)

Parameters

newList IEnumerable<T>

Remarks

Equivalent to Clear() followed by AddRange(newList), but slightly more efficient.

SecondToLastOrDefault()

public T? SecondToLastOrDefault()

Returns

T

SwapRemoveAt(int)

Remove item at index index in O(1) by swapping it with the last element in the collection.

public void SwapRemoveAt(int index)

Parameters

index int