Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
interval_t Struct Reference

Public Member Functions

void Normalize (int64_t &months, int64_t &days, int64_t &micros) const
interval_t Normalize () const
bool operator== (const interval_t &right) const
bool operator!= (const interval_t &right) const
bool operator> (const interval_t &right) const
bool operator< (const interval_t &right) const
bool operator<= (const interval_t &right) const
bool operator>= (const interval_t &right) const
void Serialize (Serializer &serializer) const

Static Public Member Functions

static void Borrow (const int64_t msf, int64_t &lsf, int32_t &f, const int64_t scale)
static interval_t Deserialize (Deserializer &source)

Public Attributes

int32_t months
int32_t days
int64_t micros

Member Function Documentation

◆ Normalize() [1/2]

void duckdb::interval_t::Normalize ( int64_t & months,
int64_t & days,
int64_t & micros ) const
inline
5334 {
5335 auto &input = *this;
5336
5337 // Carry left
5338 micros = input.micros;
5339 int64_t carry_days = micros / Interval::MICROS_PER_DAY;
5340 micros -= carry_days * Interval::MICROS_PER_DAY;
5341
5342 days = input.days;
5343 days += carry_days;
5344 int64_t carry_months = days / Interval::DAYS_PER_MONTH;
5345 days -= carry_months * Interval::DAYS_PER_MONTH;
5346
5347 months = input.months;
5348 months += carry_months;
5349}
::int64_t int64_t

◆ Normalize() [2/2]

interval_t duckdb::interval_t::Normalize ( ) const
inline
5363 {
5364 interval_t result;
5365
5366 int64_t mm;
5367 int64_t dd;
5368 Normalize(mm, dd, result.micros);
5369
5370 // Borrow right on overflow
5371 Borrow(mm, dd, result.months, Interval::DAYS_PER_MONTH);
5372 Borrow(dd, result.micros, result.days, Interval::MICROS_PER_DAY);
5373
5374 return result;
5375}

◆ Borrow()

void duckdb::interval_t::Borrow ( const int64_t msf,
int64_t & lsf,
int32_t & f,
const int64_t scale )
inlinestatic
5351 {
5352 if (msf > NumericLimits<int32_t>::Maximum()) {
5353 f = NumericLimits<int32_t>::Maximum();
5354 lsf += (msf - f) * scale;
5355 } else if (msf < NumericLimits<int32_t>::Minimum()) {
5356 f = NumericLimits<int32_t>::Minimum();
5357 lsf += (msf - f) * scale;
5358 } else {
5359 f = UnsafeNumericCast<int32_t>(msf);
5360 }
5361}

◆ operator==()

bool duckdb::interval_t::operator== ( const interval_t & right) const
inline
5192 {
5193 // Quick equality check
5194 const auto &left = *this;
5195 if (left.months == right.months && left.days == right.days && left.micros == right.micros) {
5196 return true;
5197 }
5198
5199 int64_t lmonths, ldays, lmicros;
5200 int64_t rmonths, rdays, rmicros;
5201 left.Normalize(lmonths, ldays, lmicros);
5202 right.Normalize(rmonths, rdays, rmicros);
5203
5204 return lmonths == rmonths && ldays == rdays && lmicros == rmicros;
5205 }

◆ operator!=()

bool duckdb::interval_t::operator!= ( const interval_t & right) const
inline
5206 {
5207 return !(*this == right);
5208 }

◆ operator>()

bool duckdb::interval_t::operator> ( const interval_t & right) const
inline
5210 {
5211 const auto &left = *this;
5212 int64_t lmonths, ldays, lmicros;
5213 int64_t rmonths, rdays, rmicros;
5214 left.Normalize(lmonths, ldays, lmicros);
5215 right.Normalize(rmonths, rdays, rmicros);
5216
5217 if (lmonths > rmonths) {
5218 return true;
5219 } else if (lmonths < rmonths) {
5220 return false;
5221 }
5222 if (ldays > rdays) {
5223 return true;
5224 } else if (ldays < rdays) {
5225 return false;
5226 }
5227 return lmicros > rmicros;
5228 }

◆ operator<()

bool duckdb::interval_t::operator< ( const interval_t & right) const
inline
5230 {
5231 return right > *this;
5232 }

◆ operator<=()

bool duckdb::interval_t::operator<= ( const interval_t & right) const
inline
5234 {
5235 return !(*this > right);
5236 }

◆ operator>=()

bool duckdb::interval_t::operator>= ( const interval_t & right) const
inline
5238 {
5239 return !(*this < right);
5240 }

◆ Serialize()

void duckdb::interval_t::Serialize ( Serializer & serializer) const
417918 {
417919 serializer.WritePropertyWithDefault<int32_t>(1, "months", months);
417920 serializer.WritePropertyWithDefault<int32_t>(2, "days", days);
417921 serializer.WritePropertyWithDefault<int64_t>(3, "micros", micros);
417922}
::int32_t int32_t

◆ Deserialize()

interval_t duckdb::interval_t::Deserialize ( Deserializer & source)
static
417924 {
417925 interval_t result;
417926 deserializer.ReadPropertyWithDefault<int32_t>(1, "months", result.months);
417927 deserializer.ReadPropertyWithDefault<int32_t>(2, "days", result.days);
417928 deserializer.ReadPropertyWithDefault<int64_t>(3, "micros", result.micros);
417929 return result;
417930}

The documentation for this struct was generated from the following files: