Vector maps in SecreC
Vector map
The table database module includes a data structure called vector map which can be used for heterogeneous vectors, for dynamically typed data or as an associative data structure (similar to Python dictionaries). The table database page describes how vector maps are used for working with databases.
A vector in a vector map contains SecreC vectors. Vector map string vectors are an exception as they can only contain SecreC strings since SecreC doesn't support string vectors.
Listing 1: Examples
import shared3p;
import shared3p_table_database;
import stdlib;
import table_database;
domain pd_shared3p shared3p;
void main() {
uint[[1]] x = {1, 2};
float[[1]] y = {30};
print("First element of 'key':");
print("Second element of 'key':");
print(
"First element of 'strings': ",
tdbVmapGetString(vmap,
"strings", 0 :: uint));
print(
"Map contains 'baz'? ",
tdbVmapCount(vmap,
"baz") > 0);
}
void printVector(T[[1]] vec)
Definition: stdlib.sc:389
void tdbVmapAddValue(uint64 id, string paramname, D T value)
Definition: shared3p_table_database.sc:92
D T tdbVmapGetValue(uint64 id, string paramname, uint64 index)
Definition: shared3p_table_database.sc:157
void tdbVmapAddString(uint64 id, string paramname, string str)
Definition: table_database.sc:180
uint64 tdbVmapCount(uint64 id, string paramname)
Definition: table_database.sc:124
void tdbVmapDelete(uint64 id)
Definition: table_database.sc:112
string tdbVmapGetString(uint64 id, string paramname, uint64 index)
Definition: table_database.sc:580
uint64 tdbVmapNew()
Definition: table_database.sc:100
uint64 tdbVmapValueVectorSize(uint64 id, string paramname)
Definition: table_database.sc:152