本文整理汇总了C++中table::end方法的典型用法代码示例。如果您正苦于以下问题:C++ table::end方法的具体用法?C++ table::end怎么用?C++ table::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table
的用法示例。
在下文中一共展示了table::end方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
}
示例3: push
void push(table& t, string key, int val)
{
if (t.find(key) == t.end())
t[key] = vector<int>();
t[key].push_back(val);
}
示例4:
//! Constructor for a distribution in the log space.
multivariate_categorical_distribution(const table<T>& lp, log_tag)
: psum_(lp.shape()) {
std::transform(lp.begin(), lp.end(), psum_.begin(), exponent<T>());
std::partial_sum(psum_.begin(), psum_.end(), psum_.begin());
}
示例5: main
int main() {
int P, i, j, prev, next;
char X;
string right;
bool complete = false;
// read in the CFG
ifstream fin("CFG.txt");
fin >> P;
for(i=0; i<P; i++) {
fin >> X >> right;
// if the first symbol on the right side of a production is a terminal,
// include it in the FIRST set of the variable on the left side of the production.
if(islower(right[0]))
FIRST[X - 'A'] |= 1 << (right[0] - 'a');
else if(productions.find(X) != productions.end())
productions[X].push_back(right);
else {
vector <string> vec;
vec.push_back(right);
productions[X] = vec;
}
}
fin.close();
// iterate until no more elements can be added to FIRST set of any variable
while(!complete) {
complete = true;
for(table::iterator it=productions.begin(); it != productions.end(); it++) {
prev = next = FIRST[it->first - 'A'];
for(vector<string>::iterator jt=(it->second).begin(); jt != (it->second).end(); jt++) {
for(i=0; i<jt->length(); i++) {
X = (*jt)[i];
if(islower(X)) {
next |= 1 << (X - 'a'); break;
}
if((FIRST[X - 'A'] & (1 << 'e' - 'a')) == 0) {
next |= FIRST[X - 'A']; break;
} else
next |= ~(~FIRST[X - 'A'] | (1 << 'e' - 'a'));
}
if(i == jt->length())
next |= (1 << 'e' - 'a');
}
if(prev != next) {
FIRST[it->first - 'A'] = next; complete = false;
}
}
}
// print out the FIRST set of each variable
for(i=0; i<26; i++)
if(FIRST[i]) {
printf("FIRST(%c) = { ", i + 'A');
for(j=0; j<26; j++)
if(FIRST[i] & (1 << j))
printf("%c ", j + 'a');
printf("}\n");
}
return 0;
}
示例6: sortByFreq
void sortByFreq(table &v) { sort(v.begin(), v.end(), comp); }
示例7: printfTable
void printfTable(table t) {
for (table::iterator it = t.begin(); it != t.end(); ++it) {
cout<< it->first << " => " << it->second << endl;
}
}
示例8: table
/**
* Copy constructor. Copies the shape and elements of a table to this one.
*/
table(const table& x)
: shape_(x.shape_), offset_(x.offset_) {
data_.reset(new T[size()]);
std::copy(x.begin(), x.end(), data());
}