本文整理汇总了C++中Rules类的典型用法代码示例。如果您正苦于以下问题:C++ Rules类的具体用法?C++ Rules怎么用?C++ Rules使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rules类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoteRules
/**
* Callback event for page redirection
*
* @param embed - the mozilla object
* @param uri - the new URL passed to the engine
* @param parent - the parent instance for this callback
*
* @return true to stop redirection event, otherwise false
*/
gint GeckoEmbed::open_uri_cb(GtkMozEmbed *embed, const char *uri, GeckoEmbed& parent) {
string target = uri;
Rules *handler;
// Determine which rules to run
if (target.find("http:") == 0
|| target.find("https:") == 0
|| target.find("about:") == 0
|| target.find("ftp:") == 0) {
cout << "applying remote rules" << endl;
handler = new RemoteRules(parent.getConfig());
}
else if (target.find("file:") == 0) {
cout << "applying local rules" << endl;
handler = new LocalRules(parent.getConfig());
}
else if (target.find("javascript:") == 0) {
cout << "applying javascript rules" << endl;
handler = new JavascriptRules(parent.getConfig());
}
else {
// URL support is limited to what the rules understand
cout << "an unsupported url was passed to the rules engine" << endl;
cout << "url string was: " << target << endl;
exit(1);
}
handler->runRules(target);
bool redirect = handler->isRedirectAllowed();
delete handler;
return !redirect;
}
示例2: _order
// Construct the H-Curve of order k
LSystem::LSystem(Rules rules, std::string ax, uint k) : _order(k), _rules(rules), _axiom(ax) {
// The production string begins as the axiom
_production = _axiom;
// For each Rule append the LHS to the nonTerminals String
for (Rules::iterator R = rules.begin(); R != rules.end(); R++) {
// (duplicates don't matter)
_nonTerminals.append(1,R->first);
}
// Do exactly 'k' rewrites of the L-System
for (int rewrites = 0; rewrites < _order; rewrites++) {
rewrite(_production);
}
// Remove all occurrences of bad commands
while (findAndRemove(_production, "+-"));
while (findAndRemove(_production, "-+"));
while (findAndRemove(_production, "A"));
while (findAndRemove(_production, "B"));
// Slightly modify the user's L-System to work with a DawBug
while (findAndReplace(_production, "F", "W$"));
while (findAndReplace(_production, "$+", "+"));
while (findAndReplace(_production, "$-", "-"));
}
示例3: conforming
bool Codeword::conforming(const Rules &rules) const
{
if (!rules)
return false;
// Check pegs.
for (int p = 0; p < rules.pegs(); ++p)
{
if (_digit[p] < 0)
return false;
}
for (int p = rules.pegs(); p < MM_MAX_PEGS; ++p)
{
if (_digit[p] >= 0)
return false;
}
// Check colors.
if (!rules.repeatable())
{
for (int c = 0; c < rules.colors(); ++c)
{
if (_counter[c] > 1)
return false;
}
}
for (int c = rules.colors(); c < MM_MAX_COLORS; ++c)
{
if (_counter[c] > 0)
return false;
}
return true;
}
示例4: openInitial
void openInitial(Possibilities &possib, Rules &rules)
{
for (Rules::iterator i = rules.begin(); i != rules.end(); i++) {
Rule *r = *i;
if (r->applyOnStart())
r->apply(possib);
}
}
示例5: checkWithRules
bool Player:: checkWithRules(const int &index, const int &buttonX, const int &buttonY,const bool &playerNr,Pieces *gamePlane[][8]){
Rules regler;
return regler.checkRulesForType(pieces ,index, buttonX, buttonY,playerNr,gamePlane);
//sedan skall regler kolla regler för pjäsen om den får flytta till buttonX och buttonY
//om den får göra det retunera true annars false
}
示例6: on_actionRules_triggered
void MainWindow::on_actionRules_triggered()
{
if (Rules::opened)
Rules::rulesDlg->activateWindow();
else
{
Rules dlg;
dlg.exec();
}
}
示例7: localDBSCAN
Rules HPDBSCAN::localDBSCAN(const Space& space, const float epsilon, const size_t minPoints)
{
const float EPS2 = std::pow(epsilon, 2);
const size_t lower = 0;
const size_t upper = this->m_points.size();
Rules rules;
// local dbscan
size_t cell = NOT_VISITED;
std::vector<size_t> neighborPoints;
#pragma omp parallel for schedule(dynamic, 500) private(neighborPoints) firstprivate(cell) reduction(merge: rules)
for (size_t point = lower; point < upper; ++point)
{
size_t pointCell = this->m_points.cell(point);
if (pointCell != cell)
{
neighborPoints = space.getNeighbors(pointCell);
cell = pointCell;
}
std::vector<size_t> minPointsArea;
ssize_t clusterId = NOISE;
if(neighborPoints.size() >= minPoints)
{
clusterId =space.regionQuery(point, neighborPoints, EPS2, minPointsArea);
}
if (minPointsArea.size() >= minPoints)
{
this->m_points.cluster(point, clusterId, true);
for (size_t other : minPointsArea)
{
ssize_t otherClusterId = this->m_points.cluster(other);
if (this->m_points.corePoint(other))
{
const std::pair<Cluster, Cluster> minmax = std::minmax(otherClusterId, clusterId);
rules.update(minmax.second, minmax.first);
}
this->m_points.cluster(other, clusterId, false);
}
}
else if (this->m_points.cluster(point) == NOT_VISITED)
{
this->m_points.cluster(point, NOISE, false);
}
}
return rules;
}
示例8: foreach
void RulesList::load()
{
foreach(const QString filename, m_filenames.split(',') ) {
qDebug() << "Loading rules from:" << filename;
Rules *rules = new Rules(filename);
m_rules.append(rules);
rules->load();
m_allrepositories.append(rules->repositories());
QList<Rules::Match> matchRules = rules->matchRules();
m_allMatchRules.append( QList<Rules::Match>(matchRules));
}
}
示例9: getHintsQty
void getHintsQty(Rules &rules, int &vert, int &horiz)
{
vert = 0;
horiz = 0;
for (Rules::iterator i = rules.begin(); i != rules.end(); i++) {
Rule::ShowOptions so = (*i)->getShowOpts();
switch (so) {
case Rule::SHOW_VERT: vert++; break;
case Rule::SHOW_HORIZ: horiz++; break;
default: ;
}
}
}
示例10: EndianXfer
// Don't change this. Make Read conform to it.
ostream &PylosBoard::Write(ostream &os) const {
Rules rls = mRules;
list<Move *>::const_iterator itr;
int mvCount = EndianXfer((int)mMoveHist.size());
rls.EndSwap();
os.write((char *)&rls, sizeof(rls));
os.write((char *)&mvCount, sizeof(mvCount));
for (itr = mMoveHist.begin(); itr != mMoveHist.end(); itr++)
os << **itr;
return os;
}
示例11: EndianXfer
ostream &CheckersBoard::Write(ostream &os) const {
Rules rules = mRules;
list<Move *>::const_iterator iter;
int moveCount = EndianXfer((int)mMoveHist.size());
rules.EndSwap();
os.write((char *)&rules, sizeof(rules));
os.write((char *)&moveCount, sizeof(moveCount));
for (iter = mMoveHist.begin(); iter != mMoveHist.end(); iter++)
os << **iter;
return os;
}
示例12: CanIMoveKing
bool Player:: CanIMoveKing(bool lose, Pieces *gamePlane[][8], const bool &playerNr){
int kingX = 0;
int kingY = 0;
int index = 0;
Rules haveILost;
getKingsXAndYPos(kingX,kingY);
index = getPieceIndexWithValues(kingX,kingY);
// om den är innanför spelplanen
lose = true;
if(kingX+1 < 8){
//kolla om han kan gå dit om
if(haveILost.checkRulesForType(pieces,index,kingX+1,kingY,playerNr,gamePlane)){
lose = false;
}
}
if(kingX-1 >= 0){
if(haveILost.checkRulesForType(pieces,index,kingX-1,kingY,playerNr,gamePlane)){
lose = false;
}
}
if(kingY+1 < 8){
if(haveILost.checkRulesForType(pieces,index,kingX,kingY+1,playerNr,gamePlane)){
lose = false;
}
}
if(kingY-1 >= 0){
if(haveILost.checkRulesForType(pieces,index,kingX,kingY-1,playerNr,gamePlane)){
lose = false;
}
}
if(kingX+1 < 8 && kingY < 8){
if(haveILost.checkRulesForType(pieces,index,kingX+1,kingY+1,playerNr,gamePlane)){
lose = false;
}
}
if(kingX+1 < 8 && kingY-1 >= 0){
if(haveILost.checkRulesForType(pieces,index,kingX+1,kingY-1,playerNr,gamePlane)){
lose = false;
}
}
if(kingX-1 >= 0 && kingY+1 < 8){
if(haveILost.checkRulesForType(pieces,index,kingX-1,kingY+1,playerNr,gamePlane)){
lose = false;
}
}
if(kingX-1 >= 0 && kingY-1 >= 0){
if(haveILost.checkRulesForType(pieces,index,kingX-1,kingY-1,playerNr,gamePlane)){
lose = false;
}
}
return lose;
}
示例13: applyRules
/**
* Internal Operations
*/
void HPDBSCAN::applyRules(const Rules& rules)
{
#pragma omp parallel for
for (size_t i = 0; i < this->m_points.size(); ++i)
{
const bool core = this->m_points.corePoint(i);
ssize_t cluster = this->m_points.cluster(i);
ssize_t found = rules.rule(cluster);
while (found < NOISE)
{
cluster = found;
found = rules.rule(found);
}
this->m_points.overrideCluster(i, cluster, core);
}
}
示例14: removeRules
static void removeRules(SolvedPuzzle &puzzle, Rules &rules)
{
bool possible;
do {
possible = false;
for (Rules::iterator i = rules.begin(); i != rules.end(); i++) {
Rule *rule = *i;
Rules excludedRules = rules;
excludedRules.remove(rule);
if (canSolve(puzzle, excludedRules)) {
possible = true;
rules.remove(rule);
delete rule;
break;
}
}
} while (possible);
}
示例15: TEST
TEST(Rules, reference) {
Rules r { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, { 358, 288, 2 } };
ASSERT_EQ(r[0], (Rule {1, 2, 3}));
ASSERT_EQ(r[1], (Rule {4, 5, 6}));
ASSERT_EQ(r[2], (Rule {7, 8, 9}));
ASSERT_EQ(r.size(), size_t(4));
swap(r[0], r[1]);
ASSERT_EQ(r[0], (Rule {4, 5, 6}));
ASSERT_EQ(r[1], (Rule {1, 2, 3}));
std::sort(r.begin(), r.end(), rule_compare {});
ASSERT_EQ(r[0], (Rule {1, 2, 3}));
ASSERT_EQ(r[1], (Rule {4, 5, 6}));
ASSERT_EQ(r[2], (Rule {7, 8, 9}));
ASSERT_EQ(r.size(), size_t(4));
}