49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include <iostream>
|
|
#include "linearList.h"
|
|
#include "arrayList.h"
|
|
/*
|
|
NEEDED TEST:
|
|
ok int capacity();
|
|
ok bool empty() const;//If empty, return 0;
|
|
ok int size() const; //Return Array Size
|
|
ok virtual T& get(int theIndex) const override; // Return Arr[theIndex]
|
|
ok virtual int indexOf(const T & theElement) const override; //Return the index of "theElement" first appeared
|
|
ok virtual void erase(int theIndex) override; //Erase Arr[theIndex]
|
|
ok virtual T* changeLength(T * x, int oldlength, int newlength) override;
|
|
ok virtual void insert(int theIndex, const T & theElement) override; //Insert theElement to place Arr[theIndex]
|
|
ok virtual void output(std::ostream & out) const override; //cout
|
|
*/
|
|
int main() {
|
|
arrayList<int> test(10);
|
|
std::cout << "ArrayCapacity: " << test.capacity() << std::endl;
|
|
std::cout << "Is Empty: " << test.empty() << std::endl;
|
|
for (int i = 0; i < 10; i++) {
|
|
test.insert(i, i + 1);
|
|
}
|
|
test.output();
|
|
std::cout << test.get(4) << std::endl ; //output 5
|
|
test.insert(10, 11); // 1 2 3 4 5 6 7 8 9 10 11
|
|
test.output();
|
|
std::cout << test.size() << std::endl;
|
|
test.erase(0); // 2 3 4 5 6 7 8 9 10 11
|
|
test.output();
|
|
|
|
test.insert(5, 3);
|
|
test.output();
|
|
std::cout << test.indexOf(3) << std::endl;
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
Output is down below
|
|
|
|
ArrayCapacity: 0
|
|
Is Empty: 1
|
|
1 2 3 4 5 6 7 8 9 10
|
|
5
|
|
1 2 3 4 5 6 7 8 9 10 11
|
|
11
|
|
2 3 4 5 6 7 8 9 10 11
|
|
2 3 4 5 6 3 7 8 9 10 11
|
|
1
|
|
*/ |