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.