cell.h

来自「文化算法的实际应用」· C头文件 代码 · 共 82 行

H
82
字号
#ifndef CAEP_CELL_H
#define CAEP_CELL_H
#include <iostream>
#include <vector>
#include "config.h"
using namespace std;

namespace CAEP
{
	class Cell
	{
	private:

	public:
		CellType mCellType;
		int mDepth;
		vector<int> mDimension;
		int mFeasibleCount;
		int mUnFeasibleCount;
		vector<float> mLowNode;
		vector<float> mHighNode;
		vector<Cell*> mSon;
		Cell *mFather;	
		Configer &mConfiger;

		Cell(Configer& cfg):mConfiger(cfg),mDimension(cfg.TreeDim),mLowNode(cfg.VariableCount),mHighNode(cfg.VariableCount),mSon(cfg.TreeNodeCount)
		{

		}

		~Cell()
		{
			for(int i = 0; i < mSon.size(); i++)
			{
				delete mSon[i];
			}
		}
		
		static Cell* Near(int prioridad, Cell* node)
		{
			int i;
			Cell *res;

			for (; node->mFather != NULL; node = node->mFather) {
				for (i = 0; i <node->mSon.size(); i++) {
					if (node->mFather->mSon[i] == node) {
						continue;
					}
					res = Find(prioridad, node->mFather->mSon[i]);
					if (res != NULL) {
						return res;
					}
				}
			}
			return NULL;
		}

		static Cell* Find(int prioridad, Cell* node)
		{
			int i;
			Cell *res;

			if (node->mDimension[0] == -1) {
				if (node->mCellType <= prioridad) {
					return node;
				}
				else {
					return NULL;
				}
			}

			for (i = 0; i < node->mSon.size(); i++) {
				res = Find(prioridad, node->mSon[i]);
				if (res != NULL) {
					return res;
				}
			}
			return NULL;
		}
	};
}
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?