🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
ast::IntervalList类 参考

#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
 
IntervalListoperator= (const IntervalList &)=default
 
 IntervalList (IntervalList &&) noexcept=default
 
IntervalListoperator= (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 ()
 
Intervaloperator[] (size_t i)
 
const Intervaloperator[] (size_t i) const
 
Intervalat (size_t i)
 
const Intervalat (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) const
 
AST_CORE_API IntervalList unite (const IntervalList &other) const
 
AST_CORE_API IntervalList subtract (const IntervalList &other) const
 
AST_CORE_API TimeList discrete (const TimePoint &epoch, double step) const
 

静态 Public 成员函数

static AST_CORE_API IntervalList FromIntervals (const std::vector< Interval > &intervals)
 

详细描述

相对时段列表

相对时段列表以 std::vector<Interval> 的形式存储一组相对时间区间。

存储模型:

  • intervals_ : std::vector<Interval> — 相对时间区间列表

不假设列表有序或非重叠。使用方式与 std::vector<Interval> 一致, 同时提供集合运算方法(合并、交集、并集、差集)。

典型用途:

  • 覆盖分析(卫星何时可见)
  • 约束满足(多约束交集)
  • 可用窗口(通信时段)
  • 间隙分析
注解
列表可以无序。集合运算(merged、intersect 等)内部会先排序合并。
警告
在使用相对时段列表时,需要明确基准时间点(epoch)。

构造及析构函数说明

◆ IntervalList()

ast::IntervalList::IntervalList ( std::initializer_list< Interval > il)
inline

从初始化列表构造

参数
il初始化列表

成员函数说明

◆ at() [1/2]

Interval & ast::IntervalList::at ( size_t i)
inline

访问第 i 个区间(边界检查)

参数
i索引
返回
第 i 个区间

◆ at() [2/2]

const Interval & ast::IntervalList::at ( size_t i) const
inline

访问第 i 个区间(边界检查)

参数
i索引
返回
第 i 个区间

◆ contains()

bool ast::IntervalList::contains ( double t) const
inline

检查时间点 t 是否落在任一区间内

参数
t时间点(相对秒数)
返回
是否在任一区间内

◆ discrete()

TimeList ast::IntervalList::discrete ( const TimePoint & epoch,
double step ) const

将每个区间按步长离散化,拼接为 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}

参数
epoch参考历元
step离散化步长(秒,必须 > 0)
返回
TimeList 离散化后的时间点列表

◆ FromIntervals()

IntervalList ast::IntervalList::FromIntervals ( const std::vector< Interval > & intervals)
static

从区间向量构造

参数
intervals区间向量
返回
IntervalList

◆ intersect()

IntervalList ast::IntervalList::intersect ( const IntervalList & other) const

交集:同时属于当前列表和 other 的时段

参数
other另一个时段列表
返回
交集

◆ merged()

IntervalList ast::IntervalList::merged ( ) const

合并重叠/相邻区间

将列表中的区间按 start 排序,合并重叠或相邻的区间, 返回排序后无重叠的区间列表。

返回
合并后的 IntervalList

◆ mergeInPlace()

void ast::IntervalList::mergeInPlace ( )

原地合并重叠/相邻区间

直接修改当前对象,将其区间按 start 排序后合并重叠或相邻的区间。 合并后列表有序且无重叠。

注解
若需保留原始数据,请使用 merged() 获取副本。

◆ operator[]() [1/2]

Interval & ast::IntervalList::operator[] ( size_t i)
inline

访问第 i 个区间(无边界检查)

参数
i索引

◆ operator[]() [2/2]

const Interval & ast::IntervalList::operator[] ( size_t i) const
inline

访问第 i 个区间(无边界检查)

参数
i索引

◆ pop_back()

void ast::IntervalList::pop_back ( )
inline

移除最后一个区间

警告
调用前应确保列表非空,否则行为未定义(与 std::vector 一致)

◆ push_back() [1/2]

void ast::IntervalList::push_back ( const Interval & interval)
inline

追加一个区间

参数
interval区间

◆ push_back() [2/2]

void ast::IntervalList::push_back ( double start,
double stop )
inline

追加一个区间

参数
start开始时间(秒)
stop结束时间(秒)

◆ subtract()

IntervalList ast::IntervalList::subtract ( const IntervalList & other) const

差集:属于当前列表但不属于 other 的时段

参数
other另一个时段列表
返回
差集

◆ totalDuration()

double ast::IntervalList::totalDuration ( ) const
inline

总时长(所有区间 duration 之和,不考虑重叠;反向区间贡献为 0)

返回
总时长(秒)

◆ unite()

IntervalList ast::IntervalList::unite ( const IntervalList & other) const

并集:属于当前列表或 other 的时段

参数
other另一个时段列表
返回
并集

该类的文档由以下文件生成: