52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace SantaClausInc.Collections;
|
|
|
|
/// <summary>
|
|
/// Represents a stack which can be used with a generic type
|
|
/// </summary>
|
|
/// <typeparam name="TValue">Type of the values stored in the stack</typeparam>
|
|
public sealed class Stack<TValue>
|
|
{
|
|
// TODO _head field
|
|
|
|
/// <summary>
|
|
/// Creates a new instance of the <see cref="Stack{TValue}" />
|
|
/// </summary>
|
|
public Stack()
|
|
{
|
|
// TODO
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the number of items on the stack
|
|
/// </summary>
|
|
// TODO
|
|
|
|
// uncomment this once the fields are implemented to avoid redundant nullability warnings
|
|
//[MemberNotNullWhen(false, nameof(_head))]
|
|
private bool IsEmpty => false; // TODO actual implementation
|
|
|
|
/// <summary>
|
|
/// Adds an item on top of the stack
|
|
/// </summary>
|
|
/// <param name="value">Value to add</param>
|
|
public void Push(TValue value)
|
|
{
|
|
// TODO
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the top element on the stack without removing it.
|
|
/// If the stack is empty the default value for the <see cref="TValue" /> type is returned.
|
|
/// </summary>
|
|
/// <returns>Top element of the stack or default</returns>
|
|
// TODO
|
|
|
|
/// <summary>
|
|
/// Gets and removes the top element of the stack.
|
|
/// If the stack is empty the default value for the <see cref="TValue" /> type is returned.
|
|
/// </summary>
|
|
/// <returns>Top element of the stack or default</returns>
|
|
// TODO
|
|
}
|