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

Function Reverse

libs/coding/reader_writer_ops.cpp:15–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace rw_ops
14{
15void Reverse(Reader const & src, Writer & dest)
16{
17 // Read from end, reverse and write directly.
18
19 size_t const bufSz = 1024;
20 std::vector<uint8_t> buffer(bufSz);
21
22 uint64_t pos = src.Size();
23 while (pos > 0)
24 {
25 size_t const sz = pos > bufSz ? bufSz : static_cast<size_t>(pos);
26 ASSERT_GREATER_OR_EQUAL(pos, sz, ());
27
28 src.Read(pos - sz, &buffer[0], sz);
29
30 std::reverse(buffer.begin(), buffer.begin() + sz);
31
32 dest.Write(&buffer[0], sz);
33
34 pos -= sz;
35 }
36}
37} // namespace rw_ops

Callers 4

AddMethod · 0.85
BuildPostcodePointsImplFunction · 0.85

Calls 4

SizeMethod · 0.45
ReadMethod · 0.45
beginMethod · 0.45
WriteMethod · 0.45

Tested by 1