当前位置: 首页>>代码示例>>C++>>正文


C++ table类代码示例

本文整理汇总了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.");
		}
	}
}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:35,代码来源:primitive_validation.cpp

示例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;
   }
 }
开发者ID:chongbingbao,项目名称:libgm,代码行数:16,代码来源:canonical_table_ll.hpp

示例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;
}
开发者ID:vadz,项目名称:lmi.new,代码行数:10,代码来源:rate_table_tool.cpp

示例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;
 }
开发者ID:DominikMS,项目名称:sol,代码行数:7,代码来源:state.hpp

示例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]);
   }
 }
开发者ID:chongbingbao,项目名称:libgm,代码行数:12,代码来源:probability_table_ll.hpp

示例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);
	}
}
开发者ID:arshiamufti,项目名称:huffman,代码行数:14,代码来源:encode.cpp

示例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());
	}
}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:15,代码来源:primitive_validation.cpp

示例8: clear

 void clear()
 {
     _table.clear();
     _columns = _rows = 0;
     _rules.clear();
     _captures.clear();
 }
开发者ID:BenHanson,项目名称:parsertl,代码行数:7,代码来源:state_machine.hpp

示例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);
                }
            }
        }
开发者ID:BentSm,项目名称:povray,代码行数:26,代码来源:table.hpp

示例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;
  }
开发者ID:abo321,项目名称:books-code,代码行数:7,代码来源:hashtable.cpp

示例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);
}
开发者ID:MaybeS,项目名称:ITE1009,代码行数:7,代码来源:drawing.cpp

示例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);
            }
        }
开发者ID:BentSm,项目名称:povray,代码行数:29,代码来源:table.hpp

示例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_()
 {}
开发者ID:BentSm,项目名称:povray,代码行数:9,代码来源:table.hpp

示例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());
        }
开发者ID:BentSm,项目名称:povray,代码行数:9,代码来源:table.hpp

示例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';
    }
  }
开发者ID:abo321,项目名称:books-code,代码行数:10,代码来源:hashtable.cpp


注:本文中的table类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。