2023-01-26 16:02:45 +01:00
|
|
|
|
|
|
|
#include "mlpp_vector.h"
|
|
|
|
|
2023-01-27 02:57:33 +01:00
|
|
|
String MLPPVector::to_string() {
|
|
|
|
String str;
|
|
|
|
|
|
|
|
str += "[MLPPVector: ";
|
|
|
|
|
|
|
|
for (int x = 0; x < _size; ++x) {
|
|
|
|
str += String::num(_data[x]);
|
|
|
|
str += " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
str += "]";
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2023-02-09 11:40:16 +01:00
|
|
|
std::vector<real_t> MLPPVector::to_std_vector() const {
|
|
|
|
std::vector<real_t> ret;
|
|
|
|
ret.resize(size());
|
|
|
|
real_t *w = &ret[0];
|
|
|
|
memcpy(w, _data, sizeof(real_t) * _size);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MLPPVector::set_from_std_vector(const std::vector<real_t> &p_from) {
|
|
|
|
resize(p_from.size());
|
|
|
|
for (int i = 0; i < _size; i++) {
|
|
|
|
_data[i] = p_from[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MLPPVector::MLPPVector(const std::vector<real_t> &p_from) {
|
|
|
|
_size = 0;
|
|
|
|
_data = NULL;
|
|
|
|
|
|
|
|
resize(p_from.size());
|
|
|
|
for (int i = 0; i < _size; i++) {
|
|
|
|
_data[i] = p_from[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-26 16:43:54 +01:00
|
|
|
void MLPPVector::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("push_back", "elem"), &MLPPVector::push_back);
|
2023-02-06 12:20:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("add_mlpp_vector", "other"), &MLPPVector::push_back);
|
2023-01-26 16:43:54 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("remove", "index"), &MLPPVector::remove);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_unordered", "index"), &MLPPVector::remove_unordered);
|
|
|
|
ClassDB::bind_method(D_METHOD("erase", "val"), &MLPPVector::erase);
|
|
|
|
ClassDB::bind_method(D_METHOD("erase_multiple_unordered", "val"), &MLPPVector::erase_multiple_unordered);
|
|
|
|
ClassDB::bind_method(D_METHOD("invert"), &MLPPVector::invert);
|
|
|
|
ClassDB::bind_method(D_METHOD("clear"), &MLPPVector::clear);
|
|
|
|
ClassDB::bind_method(D_METHOD("reset"), &MLPPVector::reset);
|
|
|
|
ClassDB::bind_method(D_METHOD("empty"), &MLPPVector::empty);
|
2023-01-26 16:02:45 +01:00
|
|
|
|
2023-01-26 16:43:54 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("size"), &MLPPVector::size);
|
2023-01-26 17:30:23 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("resize", "size"), &MLPPVector::resize);
|
2023-01-26 16:02:45 +01:00
|
|
|
|
2023-01-26 16:43:54 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("get_element", "index"), &MLPPVector::get_element_bind);
|
2023-01-26 16:51:34 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_element", "index", "val"), &MLPPVector::set_element_bind);
|
|
|
|
|
2023-01-26 16:43:54 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("fill", "val"), &MLPPVector::fill);
|
|
|
|
ClassDB::bind_method(D_METHOD("insert", "pos", "val"), &MLPPVector::insert);
|
|
|
|
ClassDB::bind_method(D_METHOD("find", "val", "from"), &MLPPVector::find, 0);
|
|
|
|
ClassDB::bind_method(D_METHOD("sort"), &MLPPVector::sort);
|
|
|
|
ClassDB::bind_method(D_METHOD("ordered_insert", "val"), &MLPPVector::ordered_insert);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("to_pool_vector"), &MLPPVector::to_pool_vector);
|
|
|
|
ClassDB::bind_method(D_METHOD("to_byte_array"), &MLPPVector::to_byte_array);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("duplicate"), &MLPPVector::duplicate);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_from_mlpp_vector", "from"), &MLPPVector::set_from_mlpp_vector);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_from_pool_vector", "from"), &MLPPVector::set_from_pool_vector);
|
2023-01-29 15:46:55 +01:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("is_equal_approx", "with", "tolerance"), &MLPPVector::is_equal_approx, CMP_EPSILON);
|
2023-01-26 16:02:45 +01:00
|
|
|
}
|