Exemplo n.º 1
0
NS_MD_BEGIN

bool Layout::onBackButton() {
	if (_backButtonCallback) {
		return _backButtonCallback();
	} else {
		auto scene = Scene::getRunningScene();
		auto content = scene->getContentLayer();
		if (content->getNodesCount() > 2 && content->getRunningNode() == this) {
			content->popLastNode();
			return true;
		}
	}
	return false;
}
    int GeneticIndividual::getMaxNodePositionOccurance() const
    {
        vector< pair<double,int> > positionHistogram;
        int maxVal=0;
        for (int a=0;a<(int)getNodesCount();a++)
        {
            const GeneticNodeGene *node = getNode(a);
            for (int b=0;b<=(int)positionHistogram.size();b++)
            {
                if (b==(int)positionHistogram.size())
                {
                    positionHistogram.push_back(pair<double,int>(node->getDrawingPosition(),1));
                    break;
                }
                else if (fabs(positionHistogram[b].first-node->getDrawingPosition())<0.01)
                {
                    positionHistogram[b].second++;
                    maxVal = max(maxVal,positionHistogram[b].second);
                }
            }
        }

        return maxVal;
    }