phundrakstl/src/test.cc

85 lines
2.3 KiB
C++

#include "list.hh"
#include "vector.hh"
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main() {
// vector<char> test_vec = {'C', 'a', 'r', 't', 'i', 'e', 'r'};
// for (auto c : test_vec)
// cout << c << " ";
// cout << std::endl;
// for (size_t i = 0; i < test_vec.size(); ++i)
// cout << test_vec.at(i) << " ";
// cout << std::endl;
// for (size_t i = 0; i < test_vec.size(); ++i)
// cout << test_vec[i] << " ";
// cout << std::endl;
// std::for_each(std::begin(test_vec), std::end(test_vec),
// [](auto elem) { cout << elem << " "; });
// cout << std::endl;
// cout << "The front() of test_vec is : " << test_vec.front() << std::endl;
// cout << "The back() of test_vec is : " << test_vec.back() << std::endl;
// for (size_t i = 0; i < test_vec.size(); ++i)
// cout << test_vec.data()[i] << " ";
// cout << std::endl;
// for (auto itr{test_vec.cbegin()}; itr != test_vec.cend(); ++itr)
// cout << *itr << " ";
// cout << std::endl;
// for (auto itr{test_vec.rbegin()}; itr != test_vec.rend(); ++itr)
// cout << *itr << " ";
// cout << std::endl;
// cout << "Is the vector test_vec empty? " << (test_vec.empty() ? "yes" :
// "no")
// << std::endl;
// cout << "Size of test_vec: " << test_vec.size() << std::endl;
// cout << "Capacity of test_vec: " << test_vec.capacity() << std::endl;
// test_vec.shrink_to_fit();
// cout << "Capacity of test_vec after shrink_to_fit(): " <<
// test_vec.capacity()
// << std::endl;
// cout << "test_vec.clear();" << std::endl;
// // test_vec.clear();
// cout << "Is the vector test_vec empty? " << (test_vec.empty() ? "yes" :
// "no")
// << std::endl;
// cout << "Size of test_vec: " << test_vec.size() << std::endl;
// cout << "Capacity of test_vec: " << test_vec.capacity() << std::endl;
// phundrak::vector<int> myvector = {10, 20, 30};
// myvector.emplace(myvector.cbegin(), 100);
// for (auto elem : myvector)
// cout << elem << std::endl;
srand((unsigned)time(0));
phundrak::vector<int> vector1 = {1, 4, 7};
for (int i = 0; i < 1000; ++i) {
int to_input = rand() % 10;
auto it = vector1.cbegin();
for (; *it < to_input; ++it)
;
vector1.insert(it, to_input);
}
for(int elem : vector1)
cout << elem << "\n";
return 0;
}