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
duckdb_re2::ByteMapBuilder Class Reference
Collaboration diagram for duckdb_re2::ByteMapBuilder:

Public Member Functions

void Mark (int lo, int hi)
void Merge ()
void Build (uint8_t *bytemap, int *bytemap_range)

Private Member Functions

int Recolor (int oldcolor)
 ByteMapBuilder (const ByteMapBuilder &)=delete
ByteMapBuilder & operator= (const ByteMapBuilder &)=delete

Private Attributes

Bitmap256 splits_
int colors_ [256]
int nextcolor_
std::vector< std::pair< int, int > > colormap_
std::vector< std::pair< int, int > > ranges_

Constructor & Destructor Documentation

◆ ByteMapBuilder()

duckdb_re2::ByteMapBuilder::ByteMapBuilder ( )
inline
470722 {
470723 // Initial state: the [0-255] range has color 256.
470724 // This will avoid problems during the second phase,
470725 // in which we assign byte classes numbered from 0.
470726 splits_.Set(255);
470727 colors_[255] = 256;
470728 nextcolor_ = 257;
470729 }

Member Function Documentation

◆ Mark()

void duckdb_re2::ByteMapBuilder::Mark ( int lo,
int hi )
470748 {
470749 DCHECK_GE(lo, 0);
470750 DCHECK_GE(hi, 0);
470751 DCHECK_LE(lo, 255);
470752 DCHECK_LE(hi, 255);
470753 DCHECK_LE(lo, hi);
470754
470755 // Ignore any [0-255] ranges. They cause us to recolor every range, which
470756 // has no effect on the eventual result and is therefore a waste of time.
470757 if (lo == 0 && hi == 255)
470758 return;
470759
470760 ranges_.emplace_back(lo, hi);
470761}

◆ Merge()

void duckdb_re2::ByteMapBuilder::Merge ( )
470763 {
470764 for (std::vector<std::pair<int, int>>::const_iterator it = ranges_.begin();
470765 it != ranges_.end();
470766 ++it) {
470767 int lo = it->first-1;
470768 int hi = it->second;
470769
470770 if (0 <= lo && !splits_.Test(lo)) {
470771 splits_.Set(lo);
470772 int next = splits_.FindNextSetBit(lo+1);
470773 colors_[lo] = colors_[next];
470774 }
470775 if (!splits_.Test(hi)) {
470776 splits_.Set(hi);
470777 int next = splits_.FindNextSetBit(hi+1);
470778 colors_[hi] = colors_[next];
470779 }
470780
470781 int c = lo+1;
470782 while (c < 256) {
470783 int next = splits_.FindNextSetBit(c);
470784 colors_[next] = Recolor(colors_[next]);
470785 if (next == hi)
470786 break;
470787 c = next+1;
470788 }
470789 }
470790 colormap_.clear();
470791 ranges_.clear();
470792}

◆ Build()

void duckdb_re2::ByteMapBuilder::Build ( uint8_t * bytemap,
int * bytemap_range )
470794 {
470795 // Assign byte classes numbered from 0.
470796 nextcolor_ = 0;
470797
470798 int c = 0;
470799 while (c < 256) {
470800 int next = splits_.FindNextSetBit(c);
470801 uint8_t b = static_cast<uint8_t>(Recolor(colors_[next]));
470802 while (c <= next) {
470803 bytemap[c] = b;
470804 c++;
470805 }
470806 }
470807
470808 *bytemap_range = nextcolor_;
470809}
::uint8_t uint8_t

◆ Recolor()

int duckdb_re2::ByteMapBuilder::Recolor ( int oldcolor)
private
470811 {
470812 // Yes, this is a linear search. There can be at most 256
470813 // colors and there will typically be far fewer than that.
470814 // Also, we need to consider keys *and* values in order to
470815 // avoid recoloring a given range more than once per batch.
470816 std::vector<std::pair<int, int>>::const_iterator it =
470817 std::find_if(colormap_.begin(), colormap_.end(),
470818 [=](const std::pair<int, int>& kv) -> bool {
470819 return kv.first == oldcolor || kv.second == oldcolor;
470820 });
470821 if (it != colormap_.end())
470822 return it->second;
470823 int newcolor = nextcolor_;
470824 nextcolor_++;
470825 colormap_.emplace_back(oldcolor, newcolor);
470826 return newcolor;
470827}

The documentation for this class was generated from the following file: