a C++ conversion of the Java code in http://www.fuzzy.cz/en/articles/basic-principles-of-database-indexes/