This commit is contained in:
e2hang
2025-07-19 21:34:14 +08:00
parent 91e6520894
commit ce3f273487
5 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#ifndef LINEAR_LIST
#define LINEAR_LIST
#include <iostream>
template <typename T>
class linearList {
public:
virtual ~linearList() {};
virtual bool empty() const = 0; //If empty, return 0;
virtual int size() const = 0; //Return Array Size
virtual T& get(int theIndex) const = 0; // Return Arr[theIndex]
virtual int indexOf(const T& theElement) const = 0; //Return the index of "theElement" first appeared
virtual void erase(int theIndex) = 0; //Erase Arr[theIndex]
virtual T* changeLength(T* x, int oldlength, int newlength) = 0;
virtual void insert(int theIndex, const T& theElement) = 0; //Insert theElement to place Arr[theIndex]
virtual void output() const = 0; //cout
};
#endif