Skip to content

T_Cyjb_Collections_ListStack_1

CYJB edited this page Mar 20, 2024 · 7 revisions

ListStack(T) 类

表示同一任意类型的实例的大小可变的后进先出 (LIFO) 集合。 该集合还允许使用索引访问堆栈中的元素。

继承层次

System.Object
  Cyjb.Collections.ObjectModel.ReadOnlyCollectionBase(T)
    Cyjb.Collections.ListStack(T)
Namespace: Cyjb.Collections
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public class ListStack<T> : ReadOnlyCollectionBase<T>, 
	IReadOnlyList<T>, IEnumerable<T>, IEnumerable, IReadOnlyCollection<T>

类型参数

 

T
指定堆栈中的元素的类型。
  The ListStack(T) type exposes the following members.

构造函数

 

名称 说明
公共方法 ListStack(T)() 初始化 ListStack(T) 类的新实例。
公共方法 ListStack(T)(IEnumerable(T)) 使用指定集合的元素初始化 ListStack(T) 类的新实例。
公共方法 ListStack(T)(Int32) 使用指定的初始容量初始化 ListStack(T) 类的新实例。
  Back to Top

属性

 

名称 说明
公共属性 Count 获取当前集合包含的元素数。 (重写 ReadOnlyCollectionBase(T).Count.)
公共属性 Item(Index) 获取或设置堆栈距离栈顶指定偏移处的元素。
公共属性 Item(Int32) 获取或设置堆栈距离栈顶指定偏移处的元素。
  Back to Top

方法

 

名称 说明
公共方法 Clear 从当前集合中移除所有元素。
公共方法 Contains 确定当前集合是否包含指定对象。 (重写 ReadOnlyCollectionBase(T).Contains(T).)
公共方法 CopyTo 从特定的 Array 索引处开始,将当前集合 的元素复制到一个 Array 中。 (重写 ReadOnlyCollectionBase(T).CopyTo(T[], Int32).)
公共方法 EnsureCapacity 确保堆栈至少具有指定容量。
公共方法 Equals Determines whether the specified object is equal to the current object. (继承自 Object。)
受保护的方法 Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (继承自 Object。)
公共方法 GetEnumerator 返回一个循环访问集合的枚举器。 (重写 ReadOnlyCollectionBase(T).GetEnumerator().)
公共方法 GetHashCode Serves as the default hash function. (继承自 Object。)
受保护的方法 GetSyncRoot 获取一个可用于同步对当前集合的访问的对象。 (继承自 ReadOnlyCollectionBase(T)。)
公共方法 GetType Gets the Type of the current instance. (继承自 Object。)
受保护的方法 MemberwiseClone Creates a shallow copy of the current Object. (继承自 Object。)
公共方法 Peek 返回堆栈顶部的元素,但不将其移除。
公共方法 Pop() 删除并返回堆栈顶部的元素。
公共方法 Pop(Int32) 删除堆栈顶部指定个数的元素。
公共方法 Push 将指定元素推入堆栈的顶部。
公共方法 ToArray 将堆栈的元素复制到新数组中。
公共方法 ToString Returns a string that represents the current object. (继承自 Object。)
公共方法 TrimExcess 如果元素数小于当前容量的 90%,将容量设置为堆栈中的实际元素数。
公共方法 TryPeek 尝试返回堆栈顶部的元素,但不将其移除。
公共方法 TryPop 尝试删除并返回堆栈顶部的元素。
  Back to Top

扩展方法

 

名称 说明
公共扩展器方法 IsDistinct(T) 判断序列中是否不包含重复元素。 (由 EnumerableUtil 定义。)
  Back to Top

参见

Reference

Cyjb.Collections 命名空间

Clone this wiki locally