当前位置: 首页>>代码示例>>C++>>正文


C++ DoubleArray::build方法代码示例

本文整理汇总了C++中DoubleArray::build方法的典型用法代码示例。如果您正苦于以下问题:C++ DoubleArray::build方法的具体用法?C++ DoubleArray::build怎么用?C++ DoubleArray::build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DoubleArray的用法示例。


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

示例1: main

int main(int argc, char* argv[])
{

	ifstream in("../dict/words.lex");                 // input

	if(!in) {
		cout << "Cannot open input file.\n";
		return 1;
	}

	char ** buf = new char*[655350];
	int i=0;
	while(in) {
		char * str = new char[64];
		in.getline(str, 64);                // delim defaults to '\n'
		//if(in) 
		//	cout << str << endl;
		buf[i] = str;
		i++;
		if (i % 100 == 0)
			cout << i << str << endl;
	}

	in.close();

	DoubleArray* da = new DoubleArray();
	da->build(i, (char**)buf);

	da->save("../dict/dartswords.lex");

	return 0;
}
开发者ID:CallingWisdom,项目名称:pychseg,代码行数:32,代码来源:build.cpp

示例2: _tmain

int _tmain(int argc, _TCHAR* argv[])
{

	std::istrstream is("test");
	unsigned char cc;
	int pos;
	pos = is.tellg();
	while(is)
		is >> cc;
	pos = is.tellg();

	/* simple test method */
	DoubleArray* da = new DoubleArray();

	const char * buf[] = {"test", "tf", "tfcc", "zl"};

	da->build(4, (char**)buf);


	int result;

	da->exactMatchSearch("test", result);	
	printf("%d\n", result);
	da->exactMatchSearch("tfcc", result);
	printf("%d\n", result);	
	da->exactMatchSearch("zl", result);
	printf("%d\n", result);

	da->exactMatchSearch("testsdf", result);	
	printf("%d\n", result);
	da->exactMatchSearch("tfcs", result);
	printf("%d\n", result);	
	da->exactMatchSearch("sdzl", result);
	printf("%d\n", result);

	int results[20];
	int resultlen = sizeof(results);
	int ret;
	ret = da->commonPrefixSearch("test", results, resultlen);	
	printf("%d %d\n", results[0], ret);
	ret = da->commonPrefixSearch("tfcc", results, resultlen);
	printf("%d %d\n", results[0], ret);
	ret = da->commonPrefixSearch("zl", results, resultlen);
	printf("%d %d\n", results[0], ret);

	ret = da->commonPrefixSearch("testsdf", results, resultlen);	
	printf("%d %d\n", results[0], ret);
	ret = da->commonPrefixSearch("tfcsc", results, resultlen);
	printf("%d %d\n", results[0], ret);
	ret = da->commonPrefixSearch("sdzl", results, resultlen);
	printf("%d %d\n", results[0], ret);

	WordDict * w = WordDict::Instance();
	CharDict * c = CharDict::Instance();

	unsigned char c1[3] = {0xe7, 0x9a, 0x84};
	unsigned int r = c->get(c1);

	//unsigned char c2[13] = {0xe4, 0xb8, 0x80, 0xe4, 0xb8, 0x96, 0xe4, 0xb9, 0x8b, 0xe9, 0x9b, 0x84, 0x0};
	unsigned char c2[7] = {0xe4, 0xb8, 0x80, 0xe4, 0xb8, 0x80, 0x0};
	int r2 = w->exactMatchSearch((const char*)c2);

	std::cout << r << " " << r2;

	return 0;
}
开发者ID:CallingWisdom,项目名称:pychseg,代码行数:66,代码来源:test.cpp


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