本地数据库类,支持千万级数据量的本地数据库 更多...
#include <Database.hpp>
Public 成员函数 | |
bool | loadDatabase (const std::string_view &database_path) |
从文件加载数据库到内存 | |
bool | saveDatabase (const std::string_view &database_path) |
将内存中的数据保存至文件 | |
void | append (const _LINE_type &line) |
向数据库中添加一行数据 | |
void | append (_LINE_type &&line) |
向数据库中移动一行数据 | |
void | revoke (std::size_t index) |
将数据库中指定位置的数据设置为删除状态 | |
_LINE_type & | getline (std::size_t index) |
获取数据库中指定位置的数据 | |
template<std::size_t N, class Func > | |
std::vector< std::pair< const _LINE_type *, std::size_t > > | find_index_if (Func condition) |
查找并返回所有满足condition的行 | |
template<std::size_t N, class Func > | |
std::vector< const _LINE_type * > | find_if (Func condition) |
查找并返回所有满足condition的行 | |
template<std::size_t N, class Func > | |
std::size_t | count_if (Func condition) |
查找所有满足condition的行的数量 | |
template<std::size_t N, class Func > | |
std::size_t | revoke_if (Func condition) |
查找所有满足condition的行并标记为删除状态 | |
void | print () const |
打印数据库中的前100条数据 | |
void | clear () |
清空内存中的数据库数据 | |
std::size_t | size () const |
获取当前数据库中数据总数量 | |
std::size_t | count () const |
获取当前数据库中有效数据数量 | |
Protected 成员函数 | |
virtual void | readLine (const void *input, _LINE_type &data)=0 |
读取数据的格式化函数 | |
virtual void | writeLine (void *output, const _LINE_type &data)=0 |
写入数据的格式化函数 | |
virtual void | printLine (const _LINE_type &data) const =0 |
打印一行数据的格式化函数 | |
Protected 属性 | |
std::size_t | lenth = (sizeof(Args) + ... + 0ULL) |
行数据的长度,默认为对Args中所有类型的sizeof求和 | |
本地数据库类,支持千万级数据量的本地数据库
数据库的存储格式为:
...Args | 指定表的字段类型 |
|
inline |
向数据库中移动一行数据
line | 要移动的数据 |
时间复杂度:O(1)
|
inline |
向数据库中添加一行数据
line | 要添加的数据 |
时间复杂度:O(1)
|
inline |
获取当前数据库中有效数据数量
时间复杂度:O(1)
|
inline |
查找所有满足condition的行的数量
N | 要比较的字段的索引 |
Func | 条件函数类型 |
condition | 条件函数 |
时间复杂度:O(n)
|
inline |
查找并返回所有满足condition的行
N | 要比较的字段的索引 |
Func | 条件函数类型 |
condition | 条件函数 |
时间复杂度:O(n)
|
inline |
查找并返回所有满足condition的行
N | 要比较的字段的索引 |
Func | 条件函数类型 |
condition | 条件函数 |
时间复杂度:O(n)
|
inline |
获取数据库中指定位置的数据
index | 索引 |
时间复杂度:O(1)
|
inline |
从文件加载数据库到内存
database_path | 文件路径 |
|
protectedpure virtual |
打印一行数据的格式化函数
data | 要打印的一行数据 |
在子类中,必须实现此函数
|
protectedpure virtual |
读取数据的格式化函数
input | 从文件中读取的一行数据 |
data | 进行类型格式化后的结果 |
在子类中,必须实现此函数
|
inline |
将数据库中指定位置的数据设置为删除状态
index | 索引 |
调用此函数后,数据库中对应位置的数据将被标记为删除状态,被标记的数据不会再被保存至文件中
时间复杂度:O(1)
|
inline |
查找所有满足condition的行并标记为删除状态
N | 要比较的字段的索引 |
Func | 条件函数类型 |
condition | 条件函数 |
时间复杂度:O(n)
|
inline |
将内存中的数据保存至文件
database_path | 文件路径 |
lenth | 一行数据的长度(以字节计),默认为对Args中所有类型的sizeof求和 |
|
inline |
获取当前数据库中数据总数量
时间复杂度:O(1)
|
protectedpure virtual |
写入数据的格式化函数
output | 要写入数据库的一行数据 |
data | 将要写入数据库的具有类型的数据 |
在子类中,必须实现此函数
|
protected |
行数据的长度,默认为对Args中所有类型的sizeof求和