|
🛰️航天仿真算法库 SpaceAST 0.0.1
|
#include <IntervalList.hpp>
Public 类型 | |
| using | iterator = std::vector<Interval>::iterator |
| using | const_iterator = std::vector<Interval>::const_iterator |
Public 成员函数 | |
| IntervalList ()=default | |
| ~IntervalList ()=default | |
| IntervalList (const IntervalList &)=default | |
| IntervalList & | operator= (const IntervalList &)=default |
| IntervalList (IntervalList &&) noexcept=default | |
| IntervalList & | operator= (IntervalList &&) noexcept=default |
| IntervalList (std::initializer_list< Interval > il) | |
| IntervalList (const std::vector< Interval > &intervals) | |
| IntervalList (std::vector< Interval > &&intervals) | |
| size_t | size () const noexcept |
| bool | empty () const noexcept |
| void | reserve (size_t n) |
| void | clear () |
| Interval & | operator[] (size_t i) |
| const Interval & | operator[] (size_t i) const |
| Interval & | at (size_t i) |
| const Interval & | at (size_t i) const |
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| void | push_back (const Interval &interval) |
| void | push_back (double start, double stop) |
| void | pop_back () |
| std::vector< Interval > & | intervals () noexcept |
| const std::vector< Interval > & | intervals () const noexcept |
| double | totalDuration () const |
| bool | contains (double t) const |
| AST_CORE_API IntervalList | merged () const |
| AST_CORE_API void | mergeInPlace () |
| AST_CORE_API IntervalList & | intersect (const IntervalList &other) |
| AST_CORE_API IntervalList & | unite (const IntervalList &other) |
| AST_CORE_API IntervalList & | subtract (const IntervalList &other) |
| AST_CORE_API IntervalList | intersected (const IntervalList &other) const |
| AST_CORE_API bool | intersects (const IntervalList &other) const |
| AST_CORE_API IntervalList | united (const IntervalList &other) const |
| AST_CORE_API IntervalList | subtracted (const IntervalList &other) const |
| IntervalList & | operator&= (const IntervalList &other) |
| IntervalList & | operator|= (const IntervalList &other) |
| IntervalList & | operator-= (const IntervalList &other) |
| IntervalList | operator& (const IntervalList &other) const |
| IntervalList | operator| (const IntervalList &other) const |
| IntervalList | operator- (const IntervalList &other) const |
| AST_CORE_API TimeList | discretize (const TimePoint &epoch, double step) const |
静态 Public 成员函数 | |
| static AST_CORE_API IntervalList | FromIntervals (const std::vector< Interval > &intervals) |
相对时段列表
相对时段列表以 std::vector<Interval> 的形式存储一组相对时间区间。
存储模型:
不假设列表有序或非重叠。使用方式与 std::vector<Interval> 一致, 同时提供集合运算方法(合并、交集、并集、差集)。
典型用途:
|
inline |
从初始化列表构造
| il | 初始化列表 |
|
inline |
访问第 i 个区间(边界检查)
| i | 索引 |
|
inline |
访问第 i 个区间(边界检查)
| i | 索引 |
|
inline |
检查时间点 t 是否落在任一区间内
| t | 时间点(相对秒数) |
将每个区间按步长离散化,拼接为 TimeList
区间为闭区间 [start, stop],两端点均会被包含在输出中。 对每个区间,生成序列 start, start+step, start+2*step, ... 直至 stop (最后一个点始终为 stop,即使它不落在步长网格上)。 例如:[0, 10] step=3 → {0, 3, 6, 9, 10} [0, 10] step=2 → {0, 2, 4, 6, 8, 10} 点区间 [x, x] 生成单点 {x};空区间(isEmpty())被跳过。
| epoch | 参考历元 |
| step | 离散化步长(秒,必须 > 0) |
|
static |
| IntervalList & ast::IntervalList::intersect | ( | const IntervalList & | other | ) |
| IntervalList ast::IntervalList::intersected | ( | const IntervalList & | other | ) | const |
交集(返回副本):同时属于当前列表和 other 的时段
| other | 另一个时段列表 |
| bool ast::IntervalList::intersects | ( | const IntervalList & | other | ) | const |
判断两个时段列表是否相交(非空交集,含仅相切产生的点区间)
| other | 另一个时段列表 |
| IntervalList ast::IntervalList::merged | ( | ) | const |
| void ast::IntervalList::mergeInPlace | ( | ) |
|
inline |
访问第 i 个区间(无边界检查)
| i | 索引 |
|
inline |
访问第 i 个区间(无边界检查)
| i | 索引 |
|
inline |
移除最后一个区间
|
inline |
追加一个区间
| interval | 区间 |
|
inline |
追加一个区间
| start | 开始时间(秒) |
| stop | 结束时间(秒) |
| IntervalList & ast::IntervalList::subtract | ( | const IntervalList & | other | ) |
| IntervalList ast::IntervalList::subtracted | ( | const IntervalList & | other | ) | const |
差集(返回副本):属于当前列表但不属于 other 的时段
| other | 另一个时段列表 |
|
inline |
总时长(所有区间 duration 之和,不考虑重叠;反向区间贡献为 0)
| IntervalList & ast::IntervalList::unite | ( | const IntervalList & | other | ) |
| IntervalList ast::IntervalList::united | ( | const IntervalList & | other | ) | const |
并集(返回副本):属于当前列表或 other 的时段
| other | 另一个时段列表 |