CKTIS / C#
System.Collections.Generic.Stack: praktična referenca
System.Collections.Generic.Stack: praktična referenca: Stack<T> preko Push, Peek i Pop implementira redoslijed zadnji unutra, prvi van.
Verzija: .NET API; verified on .NET 10.0.14
Sintaksa
System.Collections.Generic.Stack /* select a documented member or constructor */Stack preko Push, Peek i Pop implementira redoslijed zadnji unutra, prvi van.
Koristite ga za pretraživanje u dubinu, povijest poništavanja i izričito modeliranje radnog stoga.
Nije siguran za istodobna pisanja, a enumeracija promatra elemente bez uklanjanja.
Pop i Peek nad praznim stogom bacaju InvalidOperationException, dok TryPop i TryPeek vraćaju false.
Cijeli program doista koristi System.Collections.Generic.Stack; točno očekivani stdout jest 2.
Primjeri
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var stack = new Stack<int>();
stack.Push(1); stack.Push(2);
Console.WriteLine(stack.Pop());
Rezultat
2
Cijeli program doista koristi `System.Collections.Generic.Stack`; točno očekivani stdout jest `2`.