📄 genericstack.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace Generics
{
public class GenericStack<T>
{
// Backing store
private T[] frames;
// Stack pointer (points to the next free stack frame)
private int pointer = 0;
// Constructor (initialises the backing store)
public GenericStack(int size)
{
this.frames = new T[size];
}
// Push method (adds a value to the stack)
public void Push(T frame)
{
// Pointer overflow check omitted for simplicity
this.frames[pointer++] = frame;
}
// Pop method (removes a value from the stack)
public T Pop()
{
// Pointer underflow check omitted for simplicity
return this.frames[--pointer];
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -