C # linear Table Implementation

Source: Internet
Author: User

The basic operations of a linear table are defined as follows:
Public interface IListDS <T>
{
Int GetLength ();
Void Clear ();
Bool IsEmpty ();
Void Append (T item );
Void Insert (T item, int I );
T Delete (int I );
T GetElem (int I );
Int Locate (T value );
Void Reverse ();
Void Print ();
}

(1) sequence table definition: each element of a linear table is stored in a continuous space in the memory. In C #, the storage space occupied by arrays in the memory is a set of continuous storage areas with Random storage features. Logically adjacent data elements are physically adjacent. The code is implemented as follows:

Public class SeqList <T>: IListDS <T>
{
Private int maxSize;
Private T [] data;
Private int last;

Public T this [int index]
{
Get {return data [index];}
Set {data [index] = value ;}
}

Public int Last
{
Set {last = value ;}
Get {return last ;}
}

Public int MaxSize
{
Set {maxSize = value ;}
Get {return maxSize ;}
}

& N

Related Article

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.