#include "pip.h"
void _() {
	
//! [foreach]
PIVector<int> vec;
vec << 1 << 2 << 3;

piForeach (int & i, vec) piCout << i;
// 1
// 2
// 3

piForeach (int & i, vec) i++;
piForeach (int & i, vec) piCout << i;
// 2
// 3
// 4
//! [foreach]
//! [foreachC]
PIVector<int> vec;
vec << 1 << 2 << 3;
piForeachC (int & i, vec)
	cout << i << ", ";
// 1, 2, 3, 
piForeachC (int & i, vec)
	i++; // ERROR! const iterator
//! [foreachC]
//! [foreachR]
PIVector<int> vec;
vec << 1 << 2 << 3;
piForeachR (int & i, vec)
	cout << i << ", ";
// 3, 2, 1, 
piForeachR (int & i, vec)
	i++;
piForeachR (int & i, vec)
	cout << i << ", ";
// 4, 3, 2, 
//! [foreachR]
//! [foreachCR]
PIVector<int> vec;
vec << 1 << 2 << 3;
piForeachCR (int & i, vec)
	cout << i << ", ";
// 3, 2, 1, 
piForeachCR (int & i, vec)
	i++; // ERROR! const iterator
//! [foreachCR]

//! [PIVector::PIVector]
PIVector<char> vec(4u, 'p');
piForeachC (char i, vec)
	cout << i << ", ";
// p, p, p, p, 

piCout << PIVector<int>({1, 2, 3});
// 1, 2, 3
//! [PIVector::PIVector]
//! [PIVector::at_c]
PIVector<int> vec;
vec << 1 << 3 << 5;
for (int i = 0; i < vec.size_s(); ++i)
	cout << vec.at(i) << ", ";
// 1, 3, 5, 
//! [PIVector::at_c]
//! [PIVector::at]
PIVector<int> vec;
vec << 1 << 3 << 5;
for (int i = 0; i < vec.size_s(); ++i)
	vec.at(i) += 1;
for (int i = 0; i < vec.size_s(); ++i)
	cout << vec.at(i) << ", ";
// 2, 4, 6, 
//! [PIVector::at]
//! [PIVector::()_c]
PIVector<int> vec;
vec << 1 << 3 << 5;
for (int i = 0; i < vec.size_s(); ++i)
	cout << vec[i] << ", ";
// 1, 3, 5, 
//! [PIVector::()_c]
//! [PIVector::()]
PIVector<int> vec;
vec << 1 << 3 << 5;
for (int i = 0; i < vec.size_s(); ++i)
	vec[i] += 1;
for (int i = 0; i < vec.size_s(); ++i)
	cout << vec[i] << ", ";
// 2, 4, 6, 
//! [PIVector::()]
//! [PIVector::data_c]
PIVector<int> vec;
vec << 1 << 3 << 5;
int carr[3];
// copy data from "vec" to "carr"
memcpy(carr, vec.data(), vec.size() * sizeof(int));
for (int i = 0; i < vec.size_s(); ++i)
	cout << carr[i] << ", ";
// 1, 3, 5, 
//! [PIVector::data_c]
//! [PIVector::data]
PIVector<int> vec;
vec << 1 << 3 << 5;
int carr[2] = {12, 13};
// copy data from "carr" to "vec" with offset
memcpy(vec.data(1), carr, 2 * sizeof(int));
for (int i = 0; i < vec.size_s(); ++i)
	cout << vec[i] << ", ";
// 1, 12, 13, 
//! [PIVector::data]
//! [PIVector::resize]
PIVector<int> vec;
vec << 1 << 2;
vec.resize(4);
piForeachC (int & i, vec)
	cout << i << ", ";
// 1, 2, 0, 0, 
vec.resize(3);
piForeachC (int & i, vec)
	cout << i << ", ";
// 1, 2, 0, 
//! [PIVector::resize]
//! [PIVector::sort_0]
PIVector<int> vec;
vec << 3 << 2 << 5 << 1 << 4;
vec.sort();
piForeachC (int & i, vec)
	cout << i << ", ";
// 1, 2, 3, 4, 5, 
//! [PIVector::sort_0]
//! [PIVector::sort_1]
static int mycomp(const int * v0, const int * v1) {
	if (*v0 == *v1) return 0;
	return *v0 < *v1 ? 1 : -1;
}
PIVector<int> vec;
vec << 3 << 2 << 5 << 1 << 4;
vec.sort(mycomp);
piForeachC (int & i, vec)
	cout << i << ", ";
// 5, 4, 3, 2, 1, 
//! [PIVector::sort_1]
//! [PIVector::fill]
PIVector<char> vec;
vec << '1' << '2' << '3' << '4' << '5';
vec.fill('0');
piForeachC (char i, vec)
	cout << i << ", ";
// 0, 0, 0, 0, 0, 
//! [PIVector::fill]
//! [PIVector::remove_0]
PIVector<char> vec;
vec << '1' << '2' << '3' << '4' << '5';
vec.remove(1);
piForeachC (char i, vec)
	cout << i << ", ";
// 1, 3, 4, 5, 
//! [PIVector::remove_0]
//! [PIVector::remove_1]
PIVector<char> vec;
vec << '1' << '2' << '3' << '4' << '5';
vec.remove(2, 2);
piForeachC (char i, vec)
	cout << i << ", ";
// 1, 2, 5, 
//! [PIVector::remove_1]
//! [PIVector::removeOne]
PIVector<char> vec;
vec << '1' << '2' << '3' << '2' << '1';
vec.removeOne('2');
piForeachC (char i, vec)
	cout << i << ", ";
// 1, 3, 2, 1, 
//! [PIVector::removeOne]
//! [PIVector::removeAll]
PIVector<char> vec;
vec << '1' << '2' << '3' << '2' << '1';
vec.removeAll('2');
piForeachC (char i, vec)
	cout << i << ", ";
// 1, 3, 1, 
//! [PIVector::removeAll]
//! [PIVector::insert_0]
PIVector<char> vec;
vec << '1' << '3' << '4';
vec.insert(1, '2');
piForeachC (char i, vec)
	cout << i << ", ";
// 1, 2, 3, 4, 
//! [PIVector::insert_0]
//! [PIVector::insert_1]
PIVector<char> vec, vec2;
vec << '1' << '4' << '5';
vec2 << '2' << '3';
vec.insert(1, vec2);
piForeachC (char i, vec)
	cout << i << ", ";
// 1, 2, 3, 4, 5, 
//! [PIVector::insert_1]
//! [PIVector::ostream<<]
PIVector<char> vec;
vec << '1' << '2' << '3' << '4' << '5';
cout << vec << endl;
// {1, 2, 3, 4, 5}
//! [PIVector::ostream<<]
//! [PIVector::PICout<<]
PIVector<char> vec;
vec << '1' << '2' << '3' << '4' << '5';
piCout << vec;
// {1, 2, 3, 4, 5}
//! [PIVector::PICout<<]

};
