本文整理汇总了C++中table类的典型用法代码示例。如果您正苦于以下问题:C++ table类的具体用法?C++ table怎么用?C++ table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: require_valid_table
static void require_valid_table(const mesh& Mesh, const string_t& Name, const table& Table)
{
if(Name == "constant" && Table.column_count() && Table.row_count() != 1)
throw std::runtime_error("'constant' table must have length 1.");
for(mesh::table_t::const_iterator array_iterator = Table.begin(); array_iterator != Table.end(); ++array_iterator)
{
const array* const current_array = array_iterator->second.get();
if(!current_array)
throw std::runtime_error("NULL table array.");
const array* const first_array = Table.begin()->second.get();
if(current_array->size() != first_array->size())
throw std::runtime_error("Array length mismatch for table [" + Name + "]");
if(current_array->get_metadata_value(metadata::key::domain()) == metadata::value::point_indices_domain())
{
if(!Mesh.points)
throw std::runtime_error("Mesh missing points array.");
if(!Mesh.point_selection)
throw std::runtime_error("Mesh missing point selections array.");
require_valid_points(Mesh);
const mesh::indices_t* const indices = dynamic_cast<const mesh::indices_t*>(current_array);
if(!indices)
throw std::runtime_error("Point indices array must be an index type.");
const mesh::indices_t::const_iterator max = std::max_element(indices->begin(), indices->end());
if(max != indices->end() && *max >= Mesh.points->size())
throw std::runtime_error("Point indices array out-of-bounds.");
}
}
}
示例2: add_gradient
/**
* Adds the gradient of the expected log-likelihood of the specified
* data point to the gradient table g.
*
* \param phead the distribution over a leading set of indices of f
* \param tail a fixed assignment to the remaining indices of f
* \param w the weight of the data point
*/
void add_gradient(const table<T>& phead, const uint_vector& tail, T w,
table<T>& g) const {
assert(phead.arity() + tail.size() == g.arity());
std::size_t index = g.offset().linear(tail, phead.arity());
for (std::size_t i = 0; i < phead.size(); ++i) {
g[index + i] += phead[i] * w;
}
}
示例3: do_save_as_text_file
// Save the given table in a text file with its number as name, return the name
// of this file.
std::string do_save_as_text_file(table const& t)
{
std::ostringstream oss;
oss << t.number() << ".txt";
std::string const filename = oss.str();
t.save_as_text(filename);
return filename;
}
示例4: create_table
table create_table(T&& key, int narr = 0, int nrec = 0) {
lua_createtable(L.get(), narr, nrec);
table result(L.get());
lua_pop(L.get(), 1);
global.set(std::forward<T>(key), result);
return result;
}
示例5: add_hessian_diag
/**
* Adds the diagonal of the Hessia of the expected log-likelihoood of
* the specified data point to the Hessian diagonal h.
*/
void add_hessian_diag(const table<T>& phead, const uint_vector& tail, T w,
table<T>& h) const {
assert(phead.arity() + tail.size() == h.arity());
std::size_t index = h.offset().linear(tail, phead.arity());
for (std::size_t i = 0; i < phead.size(); ++i) {
h[index + i] -= phead[i] * w / (f[index + i] * f[index + i]);
}
}
示例6: insert
void insert(table &fTable, char c) {
bool inserted = false;
for(table::iterator it = fTable.begin(); it != fTable.end(); ++it) {
if (it->first == c) {
++(it->second);
inserted = true;
break;
}
}
if (!inserted) {
pair<char, int> ins(c, 1);
fTable.push_back(ins);
}
}
示例7: require_table_row_count
void require_table_row_count(const mesh::primitive& Primitive, const table& Table, const string_t& TableName, const uint_t RowCount)
{
if(TableName == "constant")
throw std::runtime_error("'constant' tables are automatically tested, and must have length 1.");
if(0 == Table.column_count())
return;
if(Table.row_count() != RowCount)
{
std::ostringstream buffer;
buffer << "[" << Primitive.type << "] table [" << TableName << "] incorrect length [" << Table.row_count() << "], expected [" << RowCount << "]";
throw std::runtime_error(buffer.str());
}
}
示例8: clear
void clear()
{
_table.clear();
_columns = _rows = 0;
_rules.clear();
_captures.clear();
}
示例9: assign
void assign(table const& x, true_type)
{
if (node_alloc() == x.node_alloc()) {
allocators_.assign(x.allocators_);
assign(x, false_type());
}
else {
set_hash_functions new_func_this(*this, x);
// Delete everything with current allocators before assigning
// the new ones.
delete_buckets();
allocators_.assign(x.allocators_);
// Copy over other data, all no throw.
new_func_this.commit();
mlf_ = x.mlf_;
bucket_count_ = min_buckets_for_size(x.size_);
max_load_ = 0;
// Finally copy the elements.
if (x.size_) {
static_cast<table_impl*>(this)->copy_buckets(x);
}
}
}
示例10: contains
bool contains(const table& tbl, int val)
{ // return true if tbl contains val
int hash_val = hash(val) % tbl.size();
bucket::const_iterator first = tbl[hash_val].begin();
bucket::const_iterator last = tbl[hash_val].end();
return find(first, last, val) != last;
}
示例11: draw_loop_text
void draw_loop_text(HDC * dc, table<object_text> table)
{
object_text pivot = table.getPivot();
FOREACH_TABLE(table, it, object_text)
if (it->visible)
drawText(dc, pivot.x + it->x, pivot.y + it->y, it->w, it->h, it->size, it->text);
}
示例12: move_assign
void move_assign(table& x, false_type)
{
if (node_alloc() == x.node_alloc()) {
delete_buckets();
set_hash_functions new_func_this(*this, x);
// No throw from here.
mlf_ = x.mlf_;
max_load_ = x.max_load_;
move_buckets_from(x);
new_func_this.commit();
}
else {
set_hash_functions new_func_this(*this, x);
new_func_this.commit();
mlf_ = x.mlf_;
recalculate_max_load();
if (!size_ && !x.size_) return;
if (x.size_ >= max_load_) {
create_buckets(min_buckets_for_size(x.size_));
}
else {
clear_buckets();
}
static_cast<table_impl*>(this)->move_assign_buckets(x);
}
}
示例13: table
table(table const& x, node_allocator const& a) :
functions(x),
allocators_(a,a),
bucket_count_(x.min_buckets_for_size(x.size_)),
size_(0),
mlf_(x.mlf_),
max_load_(0),
buckets_()
{}
示例14: swap_allocators
void swap_allocators(table& other, false_type)
{
boost::unordered::detail::func::ignore_unused_variable_warning(other);
// According to 23.2.1.8, if propagate_on_container_swap is
// false the behaviour is undefined unless the allocators
// are equal.
BOOST_ASSERT(node_alloc() == other.node_alloc());
}
示例15: show
void show(const table& tbl)
{ // show contents of buckets in table
for (int i = 0; i < tbl.size(); ++i)
{ // show contents of bucket i
cout << "bucket " << setw(2) << i << ": ";
copy(tbl[i].begin(), tbl[i].end(),
ostream_iterator<int>(cout, " "));
cout << '\n';
}
}