2018-02-08 16:38:06 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <ods/array.h>
|
2018-02-08 23:05:19 +00:00
|
|
|
#include <ods/array_stack.h>
|
2018-02-21 16:05:47 +00:00
|
|
|
#include <ods/array_queue.h>
|
|
|
|
#include <ods/array_deque.h>
|
2018-02-08 16:38:06 +00:00
|
|
|
using namespace std;
|
2018-02-08 23:05:19 +00:00
|
|
|
using namespace ods;
|
2018-02-08 16:38:06 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
Array<int> a(2);
|
2018-02-21 16:05:47 +00:00
|
|
|
Array<int> b(5);
|
|
|
|
|
|
|
|
cout << "=== Array ===" << endl;
|
2018-02-08 16:38:06 +00:00
|
|
|
cout << "a[0] " << a[0] << endl;
|
|
|
|
|
|
|
|
b = a;
|
2018-02-08 23:05:19 +00:00
|
|
|
cout << "b[0] " << b[0] << endl;
|
|
|
|
|
2018-02-21 16:05:47 +00:00
|
|
|
cout << "=== ArrayStack ===" << endl;
|
2018-02-08 23:05:19 +00:00
|
|
|
ArrayStack<int> as(5);
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
as.set(i, i+1);
|
|
|
|
}
|
|
|
|
as.add(1, 42);
|
|
|
|
cout << "as[0] " << as.get(0) << endl;
|
|
|
|
cout << "as[1] " << as.get(1) << endl;
|
|
|
|
as.remove(0);
|
|
|
|
cout << "as[0] " << as.get(0) << endl;
|
2018-02-20 18:09:12 +00:00
|
|
|
|
|
|
|
cout << "size: " << as.size() << ", cap: " << as.cap() << endl;
|
|
|
|
as.add(0, 47);
|
|
|
|
as.add(0, 11);
|
|
|
|
as.add(0, 17);
|
|
|
|
as.add(0, 1);
|
|
|
|
cout << "size: " << as.size() << ", cap: " << as.cap() << endl;
|
2018-02-21 16:05:47 +00:00
|
|
|
|
|
|
|
cout << "=== ArrayQueue ===" << endl;
|
|
|
|
ArrayQueue<int> aq(5);
|
|
|
|
cout << "size: " << aq.size() << ", cap: " << aq.cap() << endl;
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
aq.add(i);
|
|
|
|
}
|
|
|
|
cout << "size: " << aq.size() << ", cap: " << aq.cap() << endl;
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
aq.remove();
|
|
|
|
}
|
|
|
|
cout << "size: " << aq.size() << ", cap: " << aq.cap() << endl;
|
|
|
|
|
|
|
|
cout << "=== ArrayDeque ===" << endl;
|
|
|
|
ArrayDeque<int> ad(1);
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
ad.add(0, i);
|
|
|
|
}
|
|
|
|
cout << "size: " << ad.size() << ", cap: " << ad.cap() << endl;
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
ad.add(ad.size() - 1, i);
|
|
|
|
}
|
|
|
|
cout << "size: " << ad.size() << ", cap: " << ad.cap() << endl;
|
|
|
|
|
|
|
|
for (int i = 0; i < ad.size(); i++) {
|
|
|
|
cout << i << "\t" << ad.get(i) << endl;
|
|
|
|
}
|
2018-02-08 23:05:19 +00:00
|
|
|
}
|