Table of Contents

Class OwnedCollection<TOwner, TItem>

Namespace
AsmResolver.Collections
Assembly
AsmResolver.dll

Represents an indexed collection where each element is owned by some object, and prevents the element from being added to any other instance of the collection.

public class OwnedCollection<TOwner, TItem> : LazyList<TItem>, IList<TItem>, ICollection<TItem>, IEnumerable<TItem>, IEnumerable where TOwner : class where TItem : class, IOwnedCollectionElement<TOwner>

Type Parameters

TOwner

The type of the owner object.

TItem

The type of elements to store.

Inheritance
LazyList<TItem>
OwnedCollection<TOwner, TItem>
Implements
IList<TItem>
Inherited Members

Constructors

OwnedCollection(TOwner)

Creates a new empty collection that is owned by an object.

public OwnedCollection(TOwner owner)

Parameters

owner TOwner

The owner of the collection.

OwnedCollection(TOwner, int)

Creates a new empty collection that is owned by an object.

public OwnedCollection(TOwner owner, int capacity)

Parameters

owner TOwner

The owner of the collection.

capacity int

The initial number of elements the collection can store.

Properties

Owner

Gets the owner of the collection.

public TOwner Owner { get; }

Property Value

TOwner

Methods

AssertNotNullAndHasNoOwner(TItem?)

Verifies that the provided item is not null and not added to another list.

protected void AssertNotNullAndHasNoOwner(TItem? item)

Parameters

item TItem

The item to verify.

Exceptions

ArgumentNullException

Occurs when the item is null.

ArgumentException

Occurs when the item is already owned by another collection.

Initialize()

Initializes the list. This method is called in a thread-safe manner.

protected override void Initialize()

OnClearItems()

The method that gets called upon clearing the entire list.

protected override void OnClearItems()

OnInsertItem(int, TItem)

The method that gets called upon inserting a new item in the list.

protected override void OnInsertItem(int index, TItem item)

Parameters

index int

The index where the item is inserted at.

item TItem

The new item.

OnInsertRange(int, IEnumerable<TItem>)

The method that gets called upon inserting a collection of new items in the list.

protected override void OnInsertRange(int index, IEnumerable<TItem> items)

Parameters

index int

The index where the item is inserted at.

items IEnumerable<TItem>

The new items.

OnRemoveItem(int)

The method that gets called upon removing an item.

protected override void OnRemoveItem(int index)

Parameters

index int

The index of the element to remove.

OnSetItem(int, TItem)

The method that gets called upon replacing an item in the list.

protected override void OnSetItem(int index, TItem item)

Parameters

index int

The index that is being replaced.

item TItem

The new item.