#include <assert.h>
#include "vector_s.h"
//great, a "sortable" vector
namespace libpetey {
template <class type>
vector_s<type>::vector_s(int n) {
nel=n;
data=new float[nel];
}
template <class type>
vector_s<type>::vector_s(type *dt, int n, int ncp_flag) {
nel=n;
if (ncp_flag) {
data=&dt;
} else {
data=new float[nel];
for (int i=0; i<n; i++) {
(*data)[i]=dt[i];
}
}
}
template <class type>
vector_s<type>::~vector_s() {
}
template <class type>
type & vector_s<type>::operator [] (int ind) {
return (*data)[ind];
}
template <class type>
int vector_s<type>::operator == (vector_s<type> &other) {
assert(nel == other.nel);
for (int i=0; i<nel; i++) {
if ((*other.data)[i] != (*data)[i]) return 0;
}
return 1;
}
template <class type>
int vector_s<type>::operator > (vector_s<type> &other) {
assert(nel == other.nel);
for (int i=0; i<nel; i++) {
if ((*data)[i] > (*other.data)[i]) return 1;
else if ((*data)[i] < (*other.data)[i]) return 0;
}
return 0;
}
template <class type>
int vector_s<type>::operator < (vector_s<type> &other) {
assert(nel == other.nel);
for (int i=0; i<nel; i++) {
if ((*data)[i] < (*other.data)[i]) return 1;
else if ((*data)[i] > (*other.data)[i]) return 0;
}
return 0;
}
template <class type>
int vector_s<type>::operator >= (vector_s<type> &other) {
assert(nel == other.nel);
for (int i=0; i<nel; i++) {
if ((*data)[i] > (*other.data)[i]) return 1;
else if ((*data)[i] < (*other.data)[i]) return 0;
}
return 1;
}
template <class type>
int vector_s<type>::operator <= (vector_s<type> &other) {
assert(nel == other.nel);
for (int i=0; i<nel; i++) {
if ((*data)[i] < (*other.data)[i]) return 1;
else if ((*data)[i] > (*other.data)[i]) return 0;
}
return 1;
}
} //end fucking namespace libwhathisface...