MCPcopy Create free account
hub / github.com/comaps/comaps / Transform

Method Transform

libs/coding/move_to_front.cpp:16–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16uint8_t MoveToFront::Transform(uint8_t b)
17{
18 auto const it = std::find(m_order.begin(), m_order.end(), b);
19 ASSERT(it != m_order.end(), ());
20
21 size_t const result = std::distance(m_order.begin(), it);
22 ASSERT_LESS(result, kNumBytes, ());
23
24 std::rotate(m_order.begin(), it, it + 1);
25 ASSERT_EQUAL(m_order[0], b, ());
26 return static_cast<uint8_t>(result);
27}
28} // namespace coding

Callers 3

EncodeAndWriteBlockMethod · 0.45
ReadAndDecodeBlockMethod · 0.45
UNIT_TESTFunction · 0.45

Calls 5

findFunction · 0.85
ASSERTFunction · 0.85
distanceFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.36