MCPcopy Create free account
hub / github.com/bcndev/bytecoin / Cursor

Method Cursor

src/platform/DBmemory.cpp:66–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64size_t DBmemory::get_approximate_items_count() const { return storage.size(); }
65
66DBmemory::Cursor::Cursor(DBmemory *db, const std::string &prefix, const std::string &middle, bool forward)
67 : db(db), prefix(prefix), forward(forward) {
68 std::string start = prefix + middle;
69 std::string finish = start;
70 if (finish.size() < db->max_key_size)
71 finish += std::string(db->max_key_size - finish.size(), char(0xff)); // char('~')
72 if (forward)
73 it = db->storage.lower_bound(start);
74 else {
75 it = db->storage.upper_bound(finish);
76 if (it == db->storage.begin())
77 it = db->storage.end();
78 else
79 --it;
80 }
81 check_prefix();
82}
83
84void DBmemory::Cursor::check_prefix() {
85 if (it == db->storage.end())

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected