Java Linear table

Source: Internet
Author: User

1. linear tables can be represented by sequential storage and chained storage structures in a computer. In which the linear table represented by sequential storage structure becomes the sequential table, the linear table represented by the chain storage structure is called the linked list, and the linked list has a single linked list, a doubly linked list, and a circular linked list.

2. A linear table is a finite sequence consisting of n (n>=0) data elements, usually expressed as (a0,a1,a2.....an-1). where subscript I identifies the ordinal number of a data element in a linear table, n is the table length of a linear table, and when n=0 indicates that the linear table is an empty table.

3. for the same linear table, the values of each data element, although different, must have the same data type, and the data elements have a linear or "one-to-many" logical relationship, namely:

? 3.1 The first Data element does not have a precursor, and this data element is also called the start node.

? 3.2 The last data element has no successor, and this data element is also known as the endpoint node.

? 3.3 In addition to the first and last data elements, other data elements have only one precursor and one successor

The data structure with the above logical relation is also called linear structure, and linear table is a linear structure.

4. for linear tables, the length can be dynamically increased or shortened, any data element in a linear table can be accessed and searched, and the insertion and deletion of data elements can be performed anywhere in the linear table, and the precursors and successors of the specified data elements in a linear table can be obtained. , you can combine two linear tables into a single linear table, or split a linear table into two or more line subtypes. Its API is as follows:

? 4.1 Clear (): Place an existing linear table into an empty table

4.2 IsEmpty (): Determines if the linear table is empty, or returns true if NULL, otherwise false.

? 4.3 length (): To find the number of data elements in a linear table and return their values

4.4 Get (i): Reads and returns the value of the I data element in a linear table. Where I has a value range of 0<=i&&i<=length ()-1

? 4.5 Insert (I,X): Inserts a data element with a value of x before the first data element of the linear table. Where I is the value range of 0<=i&&i<=length (). When i==0, inserts x at the table header when I=length () indicates that it inserts x at the end of the table

4.6 Remove (i): Deletes and returns the first data element in a linear table. Where I has a value range of 0<=i&&i<=length ()-1

4.7 indexOf (x): Returns the ordinal of the first occurrence of the specified data element in a linear table, or 1 if the linear table does not contain this element

Its API corresponds to the following interface (Java):

PublicInterfacelist<t>{PublicAbstractvoidClear();PublicAbstractBooleanIsEmpty();PublicAbstractIntLength();PublicAbstractvoidInsert (int i,t x) throws Exception; public abstract T get (int i) throws Exception; public abstract int indexof (T x)  Throws Exception; public void remove (int i) throws Exception;}           

Java Linear table

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.