C # implementation sequence stack

Source: Internet
Author: User
Tags data structures

Stacks are linear tables that are limited by operations to the end of a table. The end of the table is to be inserted, deleted, and so on, so it has a special meaning, the end of the table is called the top, the other end is fixed, called the Stack Bottom (Bottom).

Stack rather than washing dishes in life, put the washed dishes up one by one (equivalent to putting the elements into the stack), and taking the plate, take the top down one after the other (equivalent to putting the elements out of the stack).

The following is the interface of the stack:

(IDs is a public interface for a variety of data structures, contains count (), IsEmpty (), clear () Three operations, previous sequential tables have been defined)

using System;
using System.Collections.Generic;
using System.Text;
namespace DateStructrues
{
  /// <summary>
  /// 栈接口
  /// </summary>
  /// <typeparam name="T">泛型</typeparam>
  public interface IStack<T> : IDS<T>
  {
    /// <summary>
    /// 入栈操作
    /// </summary>
    /// <param name="item">泛型:要入栈的元素</param>
    void Push(T item);
    /// <summary>
    /// 出栈操作
    /// </summary>
    /// <returns>出栈的元素</returns>
    T Pop();
    /// <summary>
    /// 取栈顶元素
    /// </summary>
    /// <returns>取出的元素</returns>
    T GetTop();
  }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.