本文整理汇总了C++中Assignment::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Assignment::insert方法的具体用法?C++ Assignment::insert怎么用?C++ Assignment::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assignment
的用法示例。
在下文中一共展示了Assignment::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: product
// Do actually the computation
set<Assignment> SPGParser::computeReductible(int i, int j)
{
set<Assignment> as;
// Base case
if(i == j && isType(i))
{
if(isUnit(i))
as.insert(Assignment::singleton(headType[i]));
return as;
}
if(j == i+1)
{
if(isType(i) && isType(j) && gcon(i,j))
{
as.insert(Assignment::singleton(headType[i]));
// we could add j but headType[i] == headType[j] so it's no use
}
return as;
}
if(isType(i) && isType(j) &&
isStar(i+1) &&
isStar(j-1) &&
widx[j] == widx[i]+1 &&
gcon(i,j))
{
Assignment a = Assignment::singleton(headType[i]);
a.insert(headType[j]);
as.insert(a);
return as;
}
if(isType(i) && isType(j))
{
// A1a
for(int k = i+1; k < j-1; k++)
if(isType(k) && reductible(i,k) && reductible(k+1,j))
as = as + product(assignments[i][k], assignments[k+1][j]);
// A1b
for(int k = i+1; k < j-1; k++)
if(isRB(k) && isLB(k+1) && reductible(i,k) && reductible(k+1,j))
as = as + product(assignments[i][k], assignments[k+1][j]);
// A2
if(gcon(i,j) && reductible(i+1,j-1))
{
set<Assignment> a = assignments[i+1][j-1];
Assignment rhs;
rhs.insert(headType[i]);
rhs.insert(headType[j]);
set<Assignment> b;
b.insert(rhs);
as = as + product(a, b);
}
}
// A3a
if(isLB(i) && isType(j))
{
for(int k = i+1; k < j && widx[k] == widx[i]; k++)
if(isStar(k) && reductible(k+1, j))
as = as + assignments[k+1][j];
}
// A3b
if(isRB(j) && isType(i))
{
for(int k = j-1; k > i && widx[k] == widx[j]; k--)
if(isStar(k) && reductible(i,k-1))
as = as + assignments[i][k-1];
}
// A4a
if(isType(i) && isType(j) && isStar(i+1) && gcon(i,j)
&& widx[i] != widx[j])
{
for(int k = i+1; k < j && widx[k] == widx[i]; k++)
if(isLB(k+1) && reductible(k+1,j-1))
as = as + assignments[k+1][j-1];
}
// A4b
if(isType(i) && isType(j) && isStar(j-1) && gcon(i,j)
&& widx[i] != widx[j])
{
for(int k = j-1; k > i && widx[k] == widx[j]; k--)
if(isRB(k-1) && reductible(i+1,k-1))
as = as + assignments[i+1][k-1];
}
// A4c
if(isType(i) && isType(j) &&
isStar(i+1) && isStar(j-1) &&
1 + widx[i] < widx[j] &&
gcon(i,j))
//.........这里部分代码省略.........
示例2: singleton
//! Create a singleton
Assignment Assignment::singleton(int n)
{
Assignment a;
a.insert(n);
return a;
}