Class
StackCollection<T>

Name-addressable stack of elements that preserves order and allows O(1) lookup by the element name.

Definition

Namespace:Telerik.Windows.Documents.Core.Data

Assembly:Telerik.Windows.Documents.Core.dll

Type Parameters:

T

Syntax:

cs-api-definition
public class StackCollection<T> : ICollection<T>, IEnumerable<T>, IEnumerable where T : IStackCollectionElement

Inheritance: objectStackCollection<T>

Implements: ICollection<T>IEnumerableIEnumerable<T>

Constructors

StackCollection()

Create an empty collection with indexing by element name and linked-list ordering for fast inserts.

Declaration

cs-api-definition
public StackCollection()

Properties

Count

The number of elements currently in the collection.

Declaration

cs-api-definition
public int Count { get; }

Property Value

int

The number of elements contained in the collection.

Implements ICollection<T>.Count

IsReadOnly

Gets a value indicating whether the ICollection<T> is read-only.

Declaration

cs-api-definition
public bool IsReadOnly { get; }

Property Value

bool

true if the ICollection<T> is read-only; otherwise, false.

Implements ICollection<T>.IsReadOnly

Methods

Add(T)

Push an element to the end of the stack and index it by name.

Declaration

cs-api-definition
public void Add(T item)

Parameters

item

T

The item.

Implements ICollection<T>.Add(T)

AddAfter(string, T)

Insert element after the element with the given name.

Declaration

cs-api-definition
public bool AddAfter(string presentedElementName, T element)

Parameters

presentedElementName

string

Name of the presented element.

element

T

The element.

Returns

bool

AddBefore(string, T)

Insert layer before the element with the given name.

Declaration

cs-api-definition
public bool AddBefore(string presentedElementName, T layer)

Parameters

presentedElementName

string

Name of the presented element.

layer

T

The layer.

Returns

bool

AddFirst(T)

Insert an element at the start of the stack and index it by name.

Declaration

cs-api-definition
public void AddFirst(T element)

Parameters

element

T

The element.

AddLast(T)

Append an element at the end of the stack and index it by name.

Declaration

cs-api-definition
public void AddLast(T element)

Parameters

element

T

The element.

Clear()

Removes all items from the ICollection<T>.

Declaration

cs-api-definition
public void Clear()

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Implements ICollection<T>.Clear()

Contains(T)

Check whether an element instance exists in the collection by its name.

Declaration

cs-api-definition
public bool Contains(T item)

Parameters

item

T

The item.

Returns

bool

Implements ICollection<T>.Contains(T)

Contains(string)

Check for the existence of an element by its unique name.

Declaration

cs-api-definition
public bool Contains(string elementName)

Parameters

elementName

string

Name of the element.

Returns

bool

CopyTo(T[], int)

Copy the elements to the provided array starting at the specified index while maintaining order.

Declaration

cs-api-definition
public void CopyTo(T[] array, int arrayIndex)

Parameters

array

T[]

The array.

arrayIndex

int

Index of the array.

Implements ICollection<T>.CopyTo(T[], int)

GetElementByName(string)

Find an element by its unique name and return it, or the default value if not present.

Declaration

cs-api-definition
public T GetElementByName(string elementName)

Parameters

elementName

string

Name of the element.

Returns

T

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration

cs-api-definition
public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

A IEnumerator<T> that can be used to iterate through the collection.

Implements IEnumerable<T>.GetEnumerator()

Remove(T)

Remove an element instance from the collection and its name index.

Declaration

cs-api-definition
public bool Remove(T item)

Parameters

item

T

The item.

Returns

bool

Implements ICollection<T>.Remove(T)

Remove(string)

Remove an element by name if present.

Declaration

cs-api-definition
public bool Remove(string elementName)

Parameters

elementName

string

Name of the element.

Returns

bool