• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Record函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Record函数的典型用法代码示例。如果您正苦于以下问题:C++ Record函数的具体用法?C++ Record怎么用?C++ Record使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Record函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Record

bool Equation_Array::Add_Equation (int type, char *parameters)
{
	static char *eq_text [] = {"BPR", "BPR_PLUS", "EXPONENTIAL", "CONICAL", "AKCELIK", "BPR+", "EXP", "CON", NULL};
	static Equation_Type eq_map [] = { BPR, BPR_PLUS, EXP, CONICAL, AKCELIK, BPR_PLUS, EXP, CONICAL };

	Equation *eq_ptr = (Equation *) Record (type);

	if (eq_ptr == NULL) return (false);

	if (parameters != NULL) {
		int i;
		char buffer [FIELD_BUFFER];

		parameters = Get_Token (parameters, buffer);

		for (i=0; eq_text [i] != NULL; i++) {
			if (str_cmp (buffer, eq_text [i]) == 0) {
				eq_ptr->type = eq_map [i];
				break;
			}
		}
		if (eq_text [i] == NULL) {
			if (Send_Messages ()) {
				exe->Error ("Unrecognized Equation Type = %s", buffer);
			}
			return (false);
		}
		parameters = Get_Double (parameters, &(eq_ptr->a));
		parameters = Get_Double (parameters, &(eq_ptr->b));
		parameters = Get_Double (parameters, &(eq_ptr->c));
		parameters = Get_Double (parameters, &(eq_ptr->d));

		if (eq_ptr->type == BPR || eq_ptr->type == BPR_PLUS) {
			if (eq_ptr->a < 0.01 || eq_ptr->b < 1.0 || eq_ptr->c < 0.4) {
				if (Send_Messages ()) {
					exe->Error ("BPR Equation Parameters %.2lf, %.2lf, %.2lf are Out of Range", eq_ptr->a, eq_ptr->b, eq_ptr->c);
				}
				return (false);
			}
			if (eq_ptr->type == BPR_PLUS) {
				if (eq_ptr->d <= 0.0) eq_ptr->d = 1.0;
				if (eq_ptr->d > 7.0) {
					if (Send_Messages ()) {
						exe->Error ("BPR Plus Equation Minimum Speed %.2lf is Out of Range", eq_ptr->d);
					}
					return (false);
				}
			}
		} else if (eq_ptr->type == EXP) {
			if (eq_ptr->a < 0.07 || eq_ptr->a > 7.5 || eq_ptr->b < 1.0 || eq_ptr->b > 20.0 ||
				eq_ptr->c < 30.0 || eq_ptr->c > 750.0) {
				if (Send_Messages ()) {
					exe->Error ("Exponential Equation Parameters %.2lf, %.2lf, %.1lf are Out of Range", eq_ptr->a, eq_ptr->b, eq_ptr->c);
				}
			}
		} else if (eq_ptr->type == CONICAL) {
			if (eq_ptr->a <= 1.0 || eq_ptr->a > 20.0) {
				if (Send_Messages ()) {
					exe->Error ("Conical Equation Parameter %.2lf is Out of Range (1..20)", eq_ptr->a);
				}
				return (false);
			}
			eq_ptr->b = (2 * eq_ptr->a - 1) / (2 * eq_ptr->a - 2);
		} else if (eq_ptr->type == AKCELIK) {
			if (eq_ptr->a <= 0.05 || eq_ptr->a > 2.5) {
				if (Send_Messages ()) {
					exe->Error ("AKCELIK Equation Parameter *.2lf is Out of Range (0.05..2.5)", eq_ptr->a);
				}
				return (false);
			}
		}
	} else if (type == 1) {

		eq_ptr->type = BPR;
		eq_ptr->a = 0.15;
		eq_ptr->b = 4.0;
		eq_ptr->c = 0.75;
		eq_ptr->d = 0.0;

	} else {

		Equation *prev_ptr = (Equation *) Record (type-1);

		if (prev_ptr == NULL) return (false);

		*eq_ptr = *prev_ptr;
		return (true);
	}

	if (Send_Messages ()) {
		exe->Print (1, "Equation Parameters %d = %s, A=%0.2lf",
			type, eq_text [eq_ptr->type], eq_ptr->a);

		if (eq_ptr->type != CONICAL && eq_ptr->type != AKCELIK) {
			exe->Print (0, ", B=%0.2lf, C=%.2lf", eq_ptr->b, eq_ptr->c);
		}
		if (eq_ptr->type == BPR_PLUS) {
			exe->Print (0, ", D=%.2lf", eq_ptr->d);
		}
	}
//.........这里部分代码省略.........
开发者ID:kravitz,项目名称:transims4,代码行数:101,代码来源:Equation.cpp


示例2: computePerformance

void computePerformance(double threshold = 0.8)
{
	QVector<Record> records;

    QString datasetPath = "C:/Users/XXX/Dropbox/DDTT-dataset/evaluation/userstudy/group matching";

    QString endText = ".gmatch";
    QString extension = "*.gmatch";

	QDir datasetDir(datasetPath);
	QStringList subdirs = datasetDir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);

	QStringList users;

	for (QString subdir : subdirs)
	{
		QDir d(datasetPath + "/" + subdir);

        auto matchFiles = d.entryList(QStringList() << extension, QDir::Files);
		if (matchFiles.isEmpty()) continue;

		users << subdir;

		for (QString matchFile : matchFiles)
		{
			// Get matches from file
			QFile ff(d.absolutePath() + "/" + matchFile);
			ff.open(QFile::ReadOnly | QFile::Text);
			QTextStream in(&ff);
			auto matches = in.readAll().split("\n", QString::SkipEmptyParts);

			// Shape names
            QStringList shapes = matchFile.replace(endText, "").split("-", QString::SkipEmptyParts);
            if(shapes.back() == "g") shapes.removeLast();

			bool isSwap = shapes.front() > shapes.back();

			// Add to vector
			QVector< QPair<QString, QString> > pairMatches;
			for (QString matchLine : matches)
			{
				QStringList match = matchLine.split(" ", QString::SkipEmptyParts);

				QString p = match.front();
				QString q = match.back();

				if (isSwap) std::swap(p, q);

				pairMatches << qMakePair(p, q);
			}

			//qDebug() << pairMatches;

			// Add record
			if (isSwap) std::reverse(shapes.begin(), shapes.end());
			for (auto a : pairMatches) records << Record(shapes.front(), shapes.back(), a.first, a.second, subdir);
		}
	}

	// Debug records:
	qSort(records);
	for (Record & record : records)
	{
		//qDebug() << record.p << " " << record.q << " " << record.shapeA << " " << record.shapeB << " " << record.user;
	}

	//qDebug() << "Num records =" << records.size();

	// ShapePairs/part_p/part_q/users
	QMap<QString, QMap<QString, QMap<QString, QStringList> > > part_matches;

	// Extract set of good pair-wise part correspondences
	for (Record r : records)
	{
		part_matches[r.shapeA + "|" + r.shapeB][r.p][r.q] << r.user;
	}

	// Passed threshold
	int num_users = users.size();
	
    QVector<Record> C, badC;

	for (QString shapePair : part_matches.keys())
	{
		auto cur_shape_pairs = shapePair.split("|");

		for (auto p : part_matches[shapePair].keys())
		{
			auto part_matching = part_matches[shapePair][p];

			for (auto q : part_matching.keys())
			{
				auto match = part_matching[q];

				int num_assigned = match.size();

				double v = double(num_assigned) / num_users;

				if (v >= threshold)
				{
//.........这里部分代码省略.........
开发者ID:aaronzou,项目名称:ddtt-dev,代码行数:101,代码来源:mainwindow.cpp


示例3: Info

 static inline void Info(Event event, Args&& ...args) {
     Record(EventSeverity::Info, event, ::std::forward<Args>(args)...);
 }
开发者ID:AJcravea,项目名称:mapbox-gl-native,代码行数:3,代码来源:log.hpp


示例4: Record

bool Db_Record::Set_Field_Number (int number, char *string)
{
	char *rec = Record ();

	if (rec == NULL) return (Status (RECORD_SIZE));

	int len, size, shift;
	char *ptr, *field, buffer [FIELD_BUFFER];

	//---- remove trailing blanks ----

	len = (int) strlen (string);
	ptr = string + len - 1;
	
	while (ptr > string) {
		if (*ptr != ' ') break;
		len--;
		*ptr-- = '\0';
	}

	//---- set the record pointer ----

	size = 0;
	field = ptr = rec;

	//---- locate the field number ----

	for (int i=0; i < number; i++) {
		ptr = Parse_String (ptr, buffer, sizeof (buffer));

		//---- if the field was not found add a dummy field ----

		if (ptr == NULL) {
			size = (int) strlen (rec);
			if (size + 3 >= max_size) return (Status (RECORD_SIZE));

			ptr = rec + size;

			if (*delimiters == ' ') {
				*ptr++ = '\"';
				*ptr++ = '\"';
			}
			*ptr++ = *delimiters;
			*ptr = '\0';
		}

		//---- set the field pointer ----

		if (i == number - 2) {
			field = ptr;
		}
	}

	//---- check the size of the string after the field ----

	shift = (int) strlen (ptr);
	size = (int) (field - rec);
	if (size + 2 >= max_size) return (Status (RECORD_SIZE));

	if (size + len + shift + 3 >= max_size) {
		shift -= (max_size - size - len - 3);
		if (shift < 0) shift = 0;
	}

	if (strstr (string, delimiters)) {
		if (shift) {
			memmove (field + len + 3, ptr, shift+1);
		}
		*field++ = '"';
		memcpy (field, string, len);
		*(field + len) = '"';
		*(field + len + 1) = (shift) ? *delimiters : '\0';
	} else {
		if (shift) {
			memmove (field + len + 1, ptr, shift+1);
		}
		memcpy (field, string, len);
		*(field + len) = (shift) ? *delimiters : '\0';
	}
	rec [max_size + 1] = '\0';
	return (true);
}
开发者ID:kravitz,项目名称:transims4,代码行数:82,代码来源:Db_Record.cpp


示例5: return

	Trip_Data * operator[] (int index)       { return (Record (index)); }
开发者ID:kravitz,项目名称:transims4,代码行数:1,代码来源:Trip_Data.hpp


示例6: QApplication

App::App(int &argc, char **argv)
: QApplication(argc, argv), d(new Data(this)) {
#ifdef Q_OS_LINUX
	setlocale(LC_NUMERIC,"C");
#endif
	setOrganizationName("xylosper");
	setOrganizationDomain("xylosper.net");
	setApplicationName(Info::name());
	setApplicationVersion(Info::version());
	setLocale(Record(APP_GROUP).value("locale", QLocale::system()).toLocale());

	d->addOption(LineCmd::Open, "open", tr("Open given %1 for file path or URL."), "mrl");
	d->addOption(LineCmd::Wake, QStringList() << "wake", tr("Bring the application window in front."));
	d->addOption(LineCmd::Action, "action", tr("Exectute %1 action or open %1 menu."), "id");
	d->addOption(LineCmd::LogLevel, "log-level", tr("Maximum verbosity for log. %1 should be one of nexts:")
				 % "\n    " % Log::options().join(", "), "lv");
	d->addOption(LineCmd::OpenGLDebug, "opengl-debug", tr("Turn on OpenGL debug logger."));
	d->addOption(LineCmd::Debug, "debug", tr("Turn on options for debugging."));
	d->getCommandParser(&d->cmdParser)->process(arguments());
	d->getCommandParser(&d->msgParser);
	d->execute(&d->cmdParser);

#if defined(Q_OS_MAC) && defined(CMPLAYER_RELEASE)
	static const QByteArray path = QApplication::applicationDirPath().toLocal8Bit();
	_Debug("Set $LIBQUVI_SCRIPTSDIR=\"%%\"", QApplication::applicationDirPath());
	if (setenv("LIBQUVI_SCRIPTSDIR", path.data(), 1) < 0)
		_Error("Cannot set $LIBQUVI_SCRIPTSDIR. Some streaming functions won't work.");
#endif

	setQuitOnLastWindowClosed(false);
#ifndef Q_OS_MAC
	setWindowIcon(defaultIcon());
#endif
	auto makeStyleNameList = [this] () {
		auto names = QStyleFactory::keys();
		const auto defaultName = style()->objectName();
		for (auto it = ++names.begin(); it != names.end(); ++it) {
			if (defaultName.compare(*it, Qt::CaseInsensitive) == 0) {
				const auto name = *it;
				names.erase(it);
				names.prepend(name);
				break;
			}
		}
		return names;
	};
	auto makeStyle = [this]() {
		Record r(APP_GROUP);
		auto name = r.value("style", styleName()).toString();
		if (style()->objectName().compare(name, Qt::CaseInsensitive) == 0)
			return;
		if (!d->styleNames.contains(name, Qt::CaseInsensitive))
			return;
		setStyle(QStyleFactory::create(name));
	};
	d->styleNames = makeStyleNameList();
	makeStyle();
	connect(&d->connection, &LocalConnection::messageReceived, [this] (const QString &message) {
		d->msgParser.parse(message.split("[:sep:]")); d->execute(&d->msgParser);
	});
}
开发者ID:akhilo,项目名称:cmplayer,代码行数:61,代码来源:app.cpp


示例7: assert

DB2FileLoaderRegularImpl::Record DB2FileLoaderRegularImpl::getRecord(size_t id)
{
    assert(data);
    return Record(*this, data + id * _header->RecordSize);
}
开发者ID:Jildor,项目名称:TrinityCore,代码行数:5,代码来源:DB2StorageLoader.cpp


示例8: Record

 SystemMethodTimer::~SystemMethodTimer()
 {
   Record();
   Report();
 }
开发者ID:Azurelol,项目名称:Samples,代码行数:5,代码来源:Profiler.cpp


示例9: return

	Group_Link * operator[] (int index)     { return (Record (index)); }
开发者ID:kravitz,项目名称:transims4,代码行数:1,代码来源:Group_Link.hpp


示例10: calc_algric_tree

void calc_algric_tree(algbric_node *root) {
    if (root->flag == true) 
        return;
    string table_name;
    int blockNum, offset;
    auto new_col_list = new vector<table_column *>, old_col_list = new_col_list, old_col_list2 = new_col_list;
    // auto old_col_list = catm.exist_relation((root->left->table))->cols;

    switch ( root->op ) {
        case algbric_node::DIRECT :
            root->flag = true;
            return;
        case algbric_node::PROJECTION : 
        {
            if (!root->left->flag) calc_algric_tree(root->left);
            old_col_list = catm.exist_relation((root->left->table))->cols;

            for( auto x : *(root->projection_list) ) {
                auto att = catm.exist_relation(x->relation_name)->get_column(x->attribute_name);
                new_col_list->push_back(new table_column((root->left->op == algbric_node::DIRECT ? x->attribute_name.c_str() : x->full_name.c_str()), att->data_type, att->str_len, 0 ));
            }
            table_name = create_temp_table(new_col_list);
            root->table = table_name;

            auto cursor = RecordManager.getCursor(root->left->table, catm.calc_record_size(root->left->table));
            while (cursor->next()) {
                Record r = cursor->getRecord();
                vector<record_value> result;
                for(auto i = new_col_list->begin(); i != new_col_list->end(); i++) {
                    for(auto j = old_col_list->begin(); j != old_col_list->end(); j++ ) {
                        if ( (*i)->name == (*j)->name ) {
                            result.push_back(r.values[j-old_col_list->begin()]);
                        }
                    }
                }
                RecordManager.insertRecord(table_name, Record(result, new_col_list), blockNum, offset);
            }

            if (root->left->op != algbric_node::DIRECT) catm.drop_table(root->left->table);

            root->flag = true;
            return;
        }
        case algbric_node::SELECTION : 
        {
            string left_name = root->left->table;
            old_col_list = catm.exist_relation(left_name)->cols;
            for( auto x : *(old_col_list) ) {
                new_col_list->push_back( new table_column(x->name.c_str(), x->data_type, x->str_len, x->flag ));
            }

            table_name = create_temp_table(new_col_list);
            root->table = table_name;

            condition *p = NULL, *eq = NULL;
            for(auto x : (root->conditions)) {
                if ( catm.is_indexed(x->left_attr) ) {
                    p = x;
                    if (x->op == condition::EQUALTO) 
                        eq = x;
                }
            }

            if ( eq != NULL ) p = eq;

            if ( p != NULL ) {
                cout << "Index used: " << p->left_attr->full_name << endl;
                int record_size = catm.calc_record_size(root->left->table);
                auto t = p->left_attr;
                indexIterator cursor;
                int asdf = IndexManager.selectNode(cursor, t->relation_name + "/index_" + t->attribute_name + ".db", 
                        p->op, (p->v).to_str(catm.get_data_type(t)));
                if ( asdf == 0 ) {
                    int b = 0, c = 0;
                    while (cursor.next(b, c) == 0) {
                        Record a = RecordManager.getRecord(t->relation_name, b, c, record_size);
                        if (calc_conditions(&(root->conditions), a))
                            RecordManager.insertRecord(table_name, a, blockNum, offset);
                    }
                }
            } else {
                string t = root->left->table;
                int record_size = catm.calc_record_size(t);
                indexIterator cursor;
                int asdf = IndexManager.getStarter(cursor, t + "/index_" + catm.get_primary(t) + ".db");
                if ( asdf == 0 ) {
                    int b = 0, c = 0;
                    while (cursor.next(b, c) == 0) {
                        Record a = RecordManager.getRecord(t, b, c, record_size);
                        if (calc_conditions(&(root->conditions), a))
                            RecordManager.insertRecord(table_name, a, blockNum, offset);
                    }
                }
            }

            root->flag = true;
            return;
        }
        case algbric_node::JOIN :
        {
//.........这里部分代码省略.........
开发者ID:pollow,项目名称:xyzSQL,代码行数:101,代码来源:evaluator.cpp


示例11: switch

bool Db_Base::Write_Field (Db_Field *fld, void *data, Field_Type type)
{
	if (data == 0) return (Status (NULL_POINTER));
	if (fld == 0) return (Status (NO_FIELD, false));
	if (!Record ().OK ()) return (Status (RECORD_SIZE));

	int lvalue = 0;
	unsigned uvalue = 0;
	double dvalue = 0.0;
	Dtime tvalue;
	String svalue;
	Field_Type fld_type;

	//---- convert the input data type to generic variables ----

	fld_type = fld->Type ();

	switch (fld_type) {
		default:
			return (Status (DB_ERROR));
			
		case DB_INTEGER:
			switch (type) {
				case DB_INTEGER:
					lvalue = *((int *) data);
					break;
				case DB_DOUBLE:
					dvalue = *((double *) data);
					if (dvalue > MAX_INTEGER) {
						lvalue = MAX_INTEGER;
					} else if (dvalue < -MAX_INTEGER) {
						lvalue = -MAX_INTEGER;
					} else {
						lvalue = DTOI (dvalue);
					}
					break;
				case DB_STRING:
					lvalue = ((String *) data)->Integer ();
					break;
				case DB_TIME:
					lvalue = (int) (*((Dtime *) data));
					break;
				default:
					return (Status (DB_ERROR));
			}
			break;

		case DB_UNSIGNED:
			switch (type) {
				case DB_INTEGER:
					uvalue = *((unsigned *) data);
					break;
				case DB_DOUBLE:
					dvalue = *((double *) data);
					if (dvalue > 2.0 * MAX_INTEGER) {
						uvalue = MAX_INTEGER;
						uvalue *= 2;
					} else if (dvalue < 0.0) {
						uvalue = 0;
					} else {
						uvalue = (unsigned) (dvalue + 0.5);
					}
					break;
				case DB_STRING:
					uvalue = ((String *) data)->Integer ();
					break;
				case DB_TIME:
					uvalue = (unsigned) (*((Dtime *) data));
					break;
				default:
					return (Status (DB_ERROR));
			}
			break;

		case DB_FIXED:
		case DB_DOUBLE:
			switch (type) {
				case DB_INTEGER:
					dvalue = (double) *((int *) data);
					break;
				case DB_DOUBLE:
					dvalue = *((double *) data);
					break;
				case DB_STRING:
					dvalue = ((String *) data)->Double ();
					break;
				case DB_TIME:
					dvalue = (double) *((Dtime *) data);
					break;
				default:
					return (Status (DB_ERROR));
			}
			break;
		
		case DB_STRING:
		case DB_CHAR:
			switch (type) {
				case DB_INTEGER:
					if (fld->Units () >= FACILITY_CODE) {
						External_Units (*((int *) data), fld->Units (), svalue);
//.........这里部分代码省略.........
开发者ID:kravitz,项目名称:transims5,代码行数:101,代码来源:Db_Base.cpp


示例12: Error

 static inline void Error(Event event, Args&& ...args) {
     Record(EventSeverity::Error, event, ::std::forward<Args>(args)...);
 }
开发者ID:EmronAlbert,项目名称:mapbox-gl-native,代码行数:3,代码来源:log.hpp


示例13: return

	Route_Legs * operator[] (int index)  { return ((Route_Legs *) Record (index)); }
开发者ID:kravitz,项目名称:transims4,代码行数:1,代码来源:Route_Legs.hpp


示例14: while

void Maze::search() {
    size_t row = entrance_row;
    size_t col = entrance_col;

    while (1) {
        int right = 0;
        int down = 0;
        int left = 0;
        int up = 0;

        // Ah! We have landed on a new tile
        // but haven't left our footprints!

        // First let's find out our situation:
        // Is it the exit?!
        if (row == exit_row && col == exit_col) {
            maze[row][col] = touched;
            records.push(Record(row, col, touched));
            return;
        }

        // Search for the directions we can go.
        if (col < width - 1 && maze[row][col + 1] == not_touched) {
            right = 1;
        }
        if (row < height - 1 && maze[row + 1][col] == not_touched) {
            down = 1;
        }
        if (col > 0 && maze[row][col - 1] == not_touched) {
            left = 1;
        }
        if (row > 0 && maze[row - 1][col] == not_touched) {
            up = 1;
        }

        if (right + down + left + up == 1) {
            // If we has exactly one way to go, then go!

            maze[row][col] = touched;
            records.push(Record(row, col, touched));
            if (right == 1) {
                ++col;
            } else if (down == 1) {
                ++row;
            } else if (left == 1) {
                --col;
            } else {
                --row;
            }

        } else if (right + down + left + up > 1) {
            // If we have multiple directions available,
            // then it is an intercection.

            maze[row][col] = intersection;
            records.push(Record(row, col, intersection));

            if (right == 1) {
                ++col;
            } else if (down == 1) {
                ++row;
            } else if (left == 1) {
                --col;
            } else {
                --row;
            }

        } else if (right + down + left + up == 0) {
            // Too bad! We don't have any way to go.
            // Just get back.

            while (maze[row][col] != intersection && !records.empty()) {
                maze[row][col] = wall;
                Record record = records.pop();
                row = record.row;
                col = record.col;
            }

            if (maze[row][col] != intersection && records.empty()) {
                // Oops! Dead maze!
                return;
            }

            maze[row][col] = not_touched;
            // Notice we even erase the record of the intersection.

        }

    }

}
开发者ID:mikuhatsune,项目名称:Data_and_Algorithms_Labs,代码行数:91,代码来源:maze.cpp


示例15: return

	Coordinator_Data * operator[] (int index) { return (Record (index)); }
开发者ID:kravitz,项目名称:transims4,代码行数:1,代码来源:Coordinator_Data.hpp


示例16: return

	File_Group * operator[] (int index)  { return ((File_Group *) Record (index)); }
开发者ID:kravitz,项目名称:transims4,代码行数:1,代码来源:File_Group.hpp


示例17: TEST_F

TEST_F( SegmentTest, RandomOperations )
{
	// Random interspersed operations
	std::unordered_map<TID, uint32_t> values; // TID -> testData entry
	std::vector<TID> tids;

	// Insert some baseline records
	for ( uint32_t i = 0; i < 100; ++i )
	{
		// Select string/record to insert
		uint64_t r = rand() % testData.size();
		const std::string s = testData[r];

		// Insert record
		TID tid = segment->Insert( Record( static_cast<uint32_t>(s.size()),
										   reinterpret_cast<const uint8_t*>(s.c_str()) ) );
		tids.push_back( tid );
		EXPECT_EQ( values.find( tid ), values.end() ); // TIDs should not be overwritten
		values[tid] = static_cast<uint32_t>(r);
	}

	// Random ops
	for ( uint32_t i = 0; i < 10000; ++i )
	{
		float chance = static_cast<float>(rand()) / RAND_MAX;
		if (chance < 0.70)
		{
			// Insert
			// Select string/record to insert
			uint64_t r = rand() % testData.size();
			const std::string s = testData[r];

			// Insert record
			TID tid = segment->Insert( Record( static_cast<uint32_t>(s.size()),
											   reinterpret_cast<const uint8_t*>(s.c_str()) ) );

			EXPECT_EQ( values.find( tid ), values.end() ); // TIDs should not be overwritten
			tids.push_back( tid );
			values[tid] = static_cast<uint32_t>(r);
		}
		else if (chance < 0.9)
		{
			// Update
			// Select new string / record
			TID target = tids[rand() % tids.size()];
			uint32_t r = rand() % testData.size();
			const std::string s = testData[r];

			// Replace old with new value
			bool success = segment->Update( target, Record( static_cast<uint32_t>(s.size()),
															reinterpret_cast<const uint8_t*>(s.c_str()) ) );

			EXPECT_EQ( true, success );
			values[target] = static_cast<uint32_t>(r);
		}
		else
		{
			// Remove
			uint32_t inTid = rand() % tids.size();
			TID target = tids[inTid];
			bool removeSuccess = segment->Remove( target );
			EXPECT_EQ( true, removeSuccess );
			// Remove from our tid map and tid vector as well
			values.erase( target );
			tids[inTid] = tids[tids.size() - 1];
			tids.pop_back();
		}
	}

	// Every value has to be the same as it was inserted/updated to
	for ( std::pair<TID, uint32_t> tidValue : values )
	{
		// Not removed, normal check
		const std::string& value = testData[tidValue.second];
		uint32_t len = static_cast<uint32_t>(value.size());
		Record rec = segment->Lookup( tidValue.first );
		EXPECT_EQ( len, rec.GetLen() );
		EXPECT_EQ( 0, memcmp( rec.GetData(), value.c_str(), len ) );
	}
};
开发者ID:Inch4Tk,项目名称:ModernDB2016SS,代码行数:80,代码来源:segmenttest.cpp


示例18: return

	Node_List * operator[] (int index)    { return (Record (index)); }
开发者ID:kravitz,项目名称:transims4,代码行数:1,代码来源:Node_List.hpp


示例19: GeneticAlgorithm

void GeneticAlgorithm(){

    int maxIter = 100;
    int i,j,k;
    int group[GROUP_SIZE][COUNT_FUNC];
    int oldParameter[COUNT_FUNC];
    int maxIndex;
    double sum,max,min,tmp;
    int count_record = 0;
    char output[300];

    /*初始族群*/
    InitGroup(group);



    for ( i = 0 ; i < maxIter ; i++){
        Eliminate(group);
        Crossover(group);
        Mutation(group);

        sum = 0;
        max = -1;
        min = 20;
        maxIndex = 0;
        #pragma omp parallel for
        for ( j = 0 ; j < GROUP_SIZE ; j++){
            tmp= Evalue( group[j]);

            if ( tmp > 10){
                fout = fopen("parameter.txt", "a");
                sprintf(output,"Parameter = ");
                for ( k = 0 ; k < COUNT_FUNC ; k++){
                    sprintf(output,"%s %5d",output, group[j][k]);
                }
                sprintf(output,"%s, Score = %lf\n",output,tmp);
                fprintf(fout,"%s",output);
                fclose(fout);
            }

            sum += tmp;

            if ( tmp > max ){
                max= tmp;
                maxIndex = j;
            }
            if ( tmp < min )
                min = tmp;
        }
        if ( i % 10 == 0)
            Record(group);
        printf("Level(%d) = %.2lf, %.2lf, %.2lf\n", i,max,sum/GROUP_SIZE,min);
        if ( max >= 10.5 && PlayGame(group[maxIndex]) >= 10.9)
            break;
    }

    printf("==Result==\n");
    for ( i = 0 ; i < COUNT_FUNC ; i++){
        printf(", %d", group[maxIndex][i]);
    }
    putchar('\n');

}
开发者ID:EelaiWind,项目名称:2048,代码行数:63,代码来源:Conscious_Openmp.c


示例20: assert

DBCFile::Record DBCFile::getRecord(size_t id)
{
    assert(_data);
    return Record(*this, _data + id*_recordSize);
}
开发者ID:Lbniese,项目名称:WoWCircle434,代码行数:5,代码来源:dbcfile.cpp



注:本文中的Record函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ RecreateJoint函数代码示例发布时间:2022-05-30
下一篇:
C++ ReceiveMessage函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap