class eosio::kv::table::index
Class List > eosio :: kv :: table :: index
Defines an index on an EOSIO Key Value Table. More...
Public Types
Type | Name |
---|---|
typedef table::iterator | iterator |
Public Functions
Type | Name |
---|---|
index (eosio::name name, KF && kf) | |
iterator | find (const K & key) const |
bool | exists (const K & key) const |
T | operator[] (const K & key) const |
std::optional< T > | get (const K & key) const |
iterator | begin () const |
iterator | end () const |
reverse_iterator | rbegin () const |
reverse_iterator | rend () const |
iterator | lower_bound (const K & key) const |
iterator | upper_bound (const K & key) const |
std::vector< T > | range (const K & b, const K & e) const |
void | setup () override |
Public Attributes
Type | Name |
---|---|
table_base * | tbl |
eosio::name | table_name |
eosio::name | contract_name |
eosio::name | index_name |
key_type | prefix |
Detailed Description
A Key Value Index allows a user of the table to search based on a given field. The only restrictions on that field are that it is serializable to a binary representation sortable by the KV intrinsics. Convenience functions exist to handle most of the primitive types as well as some more complex types, and are used automatically where possible.
Template parameters:
- K - The type of the key used in the index.
Public Types Documentation
typedef iterator
using eosio::kv::table< T, TableName >::index< K >::iterator = table::iterator;
Public Functions Documentation
function index
template<typename KF>
eosio::kv::table< T, TableName >::index< K >::index(
eosio::name name,
KF && kf
)
function find
iterator eosio::kv::table< T, TableName >::index< K >::find(
const K & key
) const
Search for an existing object in a table by the index, using the given key.
Parameters:
- key - The key to search for.
Returns:
An iterator to the found object OR the end
iterator if the given key was not found.
function exists
bool eosio::kv::table< T, TableName >::index< K >::exists(
const K & key
) const
Check if a given key exists in the index.
Parameters:
- key - The key to check for.
Returns:
If the key exists or not.
function operator[]
T eosio::kv::table< T, TableName >::index< K >::operator[](
const K & key
) const
Get the value for an existing object in a table by the index, using the given key.
Parameters:
- key - The key to search for.
Returns:
The value corresponding to the key.
function get
std::optional<T> eosio::kv::table< T, TableName >::index< K >::get(
const K & key
) const
Get the value for an existing object in a table by the index, using the given key.
Parameters:
- key - The key to search for.
Returns:
A std::optional of the value corresponding to the key.
function begin
iterator eosio::kv::table< T, TableName >::index< K >::begin() const
Returns an iterator to the object with the lowest key (by this index) in the table.
Returns:
An iterator to the object with the lowest key (by this index) in the table.
function end
iterator eosio::kv::table< T, TableName >::index< K >::end() const
Returns an iterator pointing past the end. It does not point to any element, therefore value
should not be called on it.
Returns:
An iterator pointing past the end.
function rbegin
reverse_iterator eosio::kv::table< T, TableName >::index< K >::rbegin() const
Returns a reverse iterator to the object with the highest key (by this index) in the table.
Returns:
A reverse iterator to the object with the highest key (by this index) in the table.
function rend
reverse_iterator eosio::kv::table< T, TableName >::index< K >::rend() const
Returns a reverse iterator pointing past the beginning. It does not point to any element, therefore value
should not be called on it.
Returns:
A reverse iterator pointing past the beginning.
function lower_bound
iterator eosio::kv::table< T, TableName >::index< K >::lower_bound(
const K & key
) const
Returns an iterator pointing to the element with the lowest key greater than or equal to the given key.
Returns:
An iterator pointing to the element with the lowest key greater than or equal to the given key.
function upper_bound
iterator eosio::kv::table< T, TableName >::index< K >::upper_bound(
const K & key
) const
Returns an iterator pointing to the first element greater than the given key.
Returns:
An iterator pointing to the first element greater than the given key.
function range
std::vector<T> eosio::kv::table< T, TableName >::index< K >::range(
const K & b,
const K & e
) const
Returns a vector of objects that fall between the specifed range. The range is inclusive, exclusive.
Parameters:
- begin - The beginning of the range (inclusive).
- end - The end of the range (exclusive).
Returns:
A vector containing all the objects that fall between the range.
function setup
void eosio::kv::table< T, TableName >::index< K >::setup()
Public Attributes Documentation
variable tbl
table_base* eosio::kv::internal::index_base::tbl;
variable table_name
eosio::name eosio::kv::internal::index_base::table_name;
variable contract_name
eosio::name eosio::kv::internal::index_base::contract_name;
variable index_name
eosio::name eosio::kv::internal::index_base::index_name;
variable prefix
key_type eosio::kv::internal::index_base::prefix;
The documentation for this class was generated from the following file: libraries/eosiolib/contracts/eosio/table.hpp