C # Implementation Order table

Source: Internet
Author: User

These days you need to implement a variety of data structures (generics). The main implementation of the linear table and linked list.

A linear table is a finite sequence consisting of n (n>=0) data elements of the same type. Except for the first element, the remaining elements have only one direct precursor; except for the last element, the remaining elements have only one direct successor.

A sequential table is a space in which the elements of a table are placed one after the other in a fast address, so the implementation of the sequential table is done with an array.

Because of the need to implement a variety of data structures, all kinds of data structures have the same method, such as the length of the request, empty and so on. So define a common interface:

namespace DateStructrues
{
  public interface IDS<T>
  {
    int Count { get;}     //求长度
    void Clear(); //清空操作
    bool IsEmpty{get;}   //判断线性表是否为空
  }
}

Linear Table Interface:

namespace DateStructrues.Lists
{
  interface IListDS<T> : IDS<T>
  {
    void Append(T item); //附加操作
    void Insert(T item, int index); //插入操作
    T Delete(int index); //删除操作
    T GetElement(int index); //取表元
    int Locate(T value); //按值查找
  }
}

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.