Files
Data-Structure/LinearList/as-Array/arrayList.h
e2hang ce3f273487 New
2025-07-19 21:34:14 +08:00

29 lines
878 B
C++

#ifndef ARRAY_LIST
#define ARRAY_LIST
#include <iostream>
#include "linearList.h"
template <typename T>
class arrayList : public linearList<T> {
public:
arrayList(int initialCapacity = 10);
arrayList(const arrayList<T>& x);
~arrayList();
int capacity();
bool empty() const;//If empty, return 0;
int size() const; //Return Array Size
virtual T& get(int theIndex) const override; // Return Arr[theIndex]
virtual int indexOf(const T& theElement) const override; //Return the index of "theElement" first appeared
virtual void erase(int theIndex) override; //Erase Arr[theIndex]
virtual T* changeLength(T* x, int oldlength, int newlength) override;
virtual void insert(int theIndex, const T& theElement) override; //Insert theElement to place Arr[theIndex]
virtual void output() const override; //cout
private:
T* element;
int arrayLength;
int listSize;
};
#endif