问题描述
我正在 Arduino 上制作航点"向量.每个航点都是一个对象.Arduino 显然需要为航点导航存储多个航点.但是,不是将这些航路点存储在标准的预编程阵列中,用户需要能够添加、删除航路点并四处移动它们.不幸的是,Arduino 没有提供矢量类型作为内置库.
I am making a vector of "waypoints" on the Arduino. Each waypoint is an object. The Arduino will obviously need to store multiple waypoints for waypoint navigation. But instead of storing these waypoints in a standard preprogrammed array, the user will need to be able to add, remove waypoints and move them around. Unfortunately the Arduino does not offer a vector type as a built-in library.
我目前正在考虑两种选择:
I am currently contemplating two options:
在像C++vector"这样的对象的容器?,有人发布了一个通用库.它不包含任何索引删除或移动操作.但它确实包含一些内存管理策略.
In Container for objects like C++ 'vector'?, someone posted a general purpose library. It does not contain any index deletion, or movement operations. But it does contain some memory management strategies.
我使用过malloc、dealloc、calloc 过去.但我根本不喜欢那个选项,尤其是在课堂上.但在我的情况下,这是一个更好的选择吗?
I have used malloc, dealloc, calloc in the past. But I do not like that option at all, especially with classes. But is this a better option in my senario?
哪条路比较好走?
推荐答案
Arduino 的标准 C++ 可能是一个选择.它允许您使用 STL vector.
Standard C++ for Arduino might be an option. It lets you use the STL vector in Arduino.
这篇关于Arduino 中的向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!