Table of Contents

Class DistinctMetadataTableBuffer<TRow>

Namespace
AsmResolver.DotNet.Builder.Metadata
Assembly
AsmResolver.DotNet.dll

Decorates a metadata table buffer with a filter that removes all duplicated rows from the buffer.

public class DistinctMetadataTableBuffer<TRow> : IMetadataTableBuffer<TRow>, IMetadataTableBuffer where TRow : struct, IMetadataRow

Type Parameters

TRow

The type of rows to store.

Inheritance
DistinctMetadataTableBuffer<TRow>
Implements
Inherited Members

Constructors

DistinctMetadataTableBuffer(UnsortedMetadataTableBuffer<TRow>)

Creates a new distinct metadata table buffer decorator.

public DistinctMetadataTableBuffer(UnsortedMetadataTableBuffer<TRow> underlyingBuffer)

Parameters

underlyingBuffer UnsortedMetadataTableBuffer<TRow>

The underlying table buffer.

Properties

Count

Gets the number of rows that were added to the buffer.

public int Count { get; }

Property Value

int

this[uint]

Gets or sets a row in the metadata table.

public TRow this[uint rid] { get; set; }

Parameters

rid uint

The identifier of the metadata row.

Property Value

TRow

Methods

Clear()

Clears the table buffer.

public void Clear()

EnsureCapacity(int)

Ensures the capacity of the table buffer is at least the provided amount of elements.

public void EnsureCapacity(int capacity)

Parameters

capacity int

The number of elements to store.

FlushToTable()

Submits all rows to the underlying table stream.

public void FlushToTable()

GetRowRef(uint)

Gets or sets a reference to a row in the metadata table.

public ref TRow GetRowRef(uint rid)

Parameters

rid uint

The identifier of the metadata row.

Returns

TRow

TryAdd(in TRow, bool, out MetadataToken)

Adds a row to the metadata table buffer.

public bool TryAdd(in TRow row, bool allowDuplicates, out MetadataToken token)

Parameters

row TRow

The row to add.

allowDuplicates bool

true if the row is always to be added to the end of the buffer, false if a duplicated row is supposed to be removed and the token of the original should be returned instead.

token MetadataToken

When the method returns true, contains the new metadata token the row was assigned to. When the method returns false, contains the previous metadata token an equivalent row was assigned to.

Returns

bool

true if the row was inserted into the table, false otherwise.

TryInsert(uint, in TRow, bool, out MetadataToken)

Inserts a row into the metadata table at the provided row identifier.

public bool TryInsert(uint rid, in TRow row, bool allowDuplicates, out MetadataToken token)

Parameters

rid uint

The row identifier.

row TRow

The row to add.

allowDuplicates bool

true if the row is always to be added to the end of the buffer, false if a duplicated row is supposed to be removed and the token of the original should be returned instead.

token MetadataToken

When the method returns true, contains the new metadata token the row was assigned to. When the method returns false, contains the previous metadata token an equivalent row was assigned to.

Returns

bool

true if the row was inserted into the table, false otherwise.