51 enum Col :
size_t { side, level, qty,
delta, live, price };
61 static_assert(
sizeof(Book::Row) == 8);
64 constexpr auto sensor_columns = [] {
65 std::array<Bit_Column, 200> columns{};
66 for (
size_t j = 0; j < columns.size(); ++j)
69 case 0: columns[j] =
bits(1);
break;
70 case 1: columns[j] =
bits(8);
break;
71 case 2: columns[j] =
bits(11);
break;
86 for (
size_t j = 0; j < Book::cols(); ++j)
87 std::cout << (j == 0 ?
"" :
", ") <<
row(j);
94 std::cout <<
"The layout that the compiler worked out\n";
95 for (
size_t j = 0; j < Book::cols(); ++j)
96 std::cout <<
" column " << j <<
": [" << Book::Row::column_min(j) <<
", "
97 << Book::Row::column_max(j) <<
"], width " << Book::Row::column_bits(j) <<
"\n";
98 std::cout <<
" a row: " << Book::Row::num_bits <<
" bits in " <<
sizeof(Book::Row)
103 std::cout <<
"Reading and writing an entry\n";
107 m.write(0, level, 9);
108 const std::int64_t q =
m(0, qty);
109 std::cout <<
" qty " << q <<
", price " <<
m.fast_read(0, price) <<
", delta "
110 <<
m.read(0, delta) <<
"\n";
116 catch (
const std::domain_error & e)
118 std::cout <<
" refused: " << e.what() <<
"\n";
124 catch (
const std::out_of_range & e)
126 std::cout <<
" refused: " << e.what() <<
"\n";
129 std::cout <<
"\nWhole rows\n";
130 m(1) = Book::Row::make(3, 2, 100, 0, 1, 500);
131 m(2) = Book::Row::fast_make(-1, 15, 7, 500, 0, 9);
132 Book::Row
row =
m(1);
135 for (
const Book::Row &
r :
m)
138 std::cout <<
"\nSorted: rows compare as their tuples do, at the cost of comparing a word\n";
140 for (
const Book::Row &
r :
m)
143 std::cout <<
"\nMany columns, described by code\n";
145 Sensors::Row reading{};
146 for (
size_t j = 0; j < Sensors::cols(); ++j)
147 reading(j) = Sensors::Row::column_max(j);
150 std::cout <<
" " << Sensors::cols() <<
" columns: " << Sensors::Row::num_bits <<
" bits in "
151 <<
sizeof(Sensors::Row) <<
" bytes per row\n"
152 <<
" column 199: " << s(0, 199) <<
" (lowest), " << s(1, 199) <<
" (highest), "
153 << s(2, 199) <<
"\n";
156 const bool sorted =
m(0) <
m(1)
and m(1) <
m(2)
and m(2) <
m(3);
158 q == 250
and m(0)(side) == -1
and m(3) == Book::Row::make(3, 2, 100, 0, 1, 500);
159 const bool sensors = s(0, 199) == -32768
and s(1, 199) == 32767
and s(2, 199) == -12345
and
160 s(1, 0) == 1
and s(1, 1) == 255
and s(1, 2) == 2047;
Matrix whose columns are bit fields: an Aleph::Array of Packed_Row.
Minimal std::expected-style result type for C++20.
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
constexpr std::uint32_t delta
File contains only the cells that changed relative to a baseline.
Main namespace for Aleph-w library functions.
constexpr Bit_Column bits(const unsigned n)
Column of n bits without sign: the integers of [0, 2^n - 1].
and
Check uniqueness with explicit hash + equality functors.
typename packed_matrix_detail::Columns_At< Columns, std::make_index_sequence< Columns.size()> >::Matrix Packed_Matrix_Of
Packed_Matrix whose columns are the entries of an array.
bool between(const Point &a, const Point &b, const Point &c)
void introsort(T *a, const long l, const long r, const Compare &cmp=Compare())
Sort an array using introsort (introspective sort).
constexpr Bit_Column signed_bits(const unsigned n)
Column of n bits with sign: the integers of [-2^(n-1), 2^(n-1) - 1].
void print(const DynList< Parc< Net > > &sp)
Print a semi-path to stdout.
FooMap m(5, fst_unit_pair_hash, snd_unit_pair_hash)
Matrix whose columns are bit fields sized from integer ranges.
Comprehensive sorting algorithms and search utilities for Aleph-w.