Implementation of linear table interfaces _ Java

Source: Internet
Author: User

A linear table is a linear structure in which elements are linearly related. The basic operations on a linear table include insert, delete, search, and replace, these operations can be performed anywhere in a linear table. Linear tables can be represented by sequential and chained storage structures.

This interface class belongs to the linearlist sub-package of the Datastructure package. The lList statement of the linear table interface is as follows, which describes basic operations such as the values, values, inserts, and deletes of a linear table.

Package Datastructure. linearlist; public interface lList <E> {Boolean isempty (); // determines whether the linear table is empty. If it is null, The tureint length () is returned (); // returns the linear table length e get (INT index); // returns the object with the serial number index, and the initial index value is 0e set (INT index, e element ); // set the serial number to the index object as element, and return the original object Boolean add (INT index, e element); // Insert the element object, after insertion, the object serial number is indexboolean add (E element); // Insert the element object. The insertion position does not specify e remove (INT index); // remove the object whose serial number is index, put it back and move the object void clear (); // clear the linear table}

The linear table class (sequence table class and linked list class) of sequential storage and chain storage implements the lList interface and provides the specific implementation of the methods in the lList interface. For example:

Public class seqlist <E> implements lList <E> // sequence table class public class singlylists list <E> implements lList <E> // single-chain table class

The methods in the lList interface show polymorphism in the sequence table class and the linked list class.

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.