zoukankan      html  css  js  c++  java
  • 线性表接口的实现_Java

    线性表是其组成元素间具有线性关系的一种线性结构,对线性表的基本操作主要有插入、删除、查找、替换等,这些操作可以在线性表的任何位置进行。线性表可以采用顺序存储结构和链式存储结构表示。

    本接口的类属于dataStructure包的linearList子包。线性表接口LList声明如下,描述线性表的取值、置值、插入、删除等基本操作。

    package dataStructure.linearList;  
      
    public interface LList<E>  
    {  
        boolean isEmpty();                  //判断线性表是否为空,若空返回ture  
        int length();                       //返回线性表长度  
        E get(int index);                   //返回序号为index的对象,index初值为0  
        E set(int index,E element);         //设置序号为index对象为element,返回原对象  
        boolean add(int index,E element);   //插入element对象,插入后对象序号为index  
        boolean add(E element);             //插入element对象,插入位置没有约定  
        E remove(int index);                //移去序号为index的对象,放回被移去对象  
        void clear();                       //清空线性表  
    }
    

    顺序存储和链式存储的线性表类(顺序表类和链表类)实现LList接口,提供LList接口中方法的具体实现。例如:

    public class SeqList<E> implements LList<E>             //顺序表类  
    public class SinglyLinkedList<E> implements LList<E>    //单链表类
    

    LList接口中的方法在顺序表类和链表类中表现出多态性。

  • 相关阅读:
    open_basedir restriction in effect的错误及其解决办法
    SNMP-网络管理协议
    安装cacti监控系统
    并发时-修改Linux系统下的最大文件描述符限制
    js new date()说明
    阿里云ECS环境部署 centos 6.5
    sysbench
    http_load
    LeetCode: Spiral Matrix
    LeetCode:Length of Last Word
  • 原文地址:https://www.cnblogs.com/ganchuanpu/p/7468482.html
Copyright © 2011-2022 走看看