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


C++ GiSTpath::MakeChild方法代码示例

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


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

示例1: MTrecord

void
MTcursor::FetchNode ()
{
	if (queue.IsEmpty()) {
		return;
	}

	MTrecord *record = queue.RemoveFirst ();
	MTnode *node = (MTnode *) tree.ReadNode (record->Path());  // retrieve next node to be examined
	delete record;

	// search the first children to be examined
	for (int i=0; i<node->NumEntries(); i++) {  // for each entry in the current node
		MTentry *entry = (MTentry *) (*node)[i].Ptr();
		double dist = pred->distance(entry->object());

		if (!entry->IsLeaf()) {  // insert the child node in the priority queue
			GiSTpath path = node->Path();
			path.MakeChild (entry->Ptr());
			queue.Insert (new MTrecord (path, MAX(dist - entry->MaxRadius(), 0), dist));
		} else {  // insert the entry in the result list
			MTentry *newEntry = (MTentry *) entry->Copy();
			newEntry->SetMinRadius(0);
			newEntry->SetMaxRadius(dist);  // we insert the actual distance from the query object as the key radius
			results.Insert (newEntry);
		}
	}

	delete node;  // delete examined node
}
开发者ID:jsc0218,项目名称:MxTree,代码行数:30,代码来源:MTcursor.cpp

示例2: ReadNode

void
MT::CollectStats ()
{
	GiSTpath path;
	path.MakeRoot ();
	GiSTnode *node = ReadNode (path);
	if (!node->IsLeaf()) {
		int maxLevel = node->Level();
		double *radii = new double[maxLevel];
		int *pages = new int[maxLevel];
		for (int i=0; i<maxLevel; i++) {
			pages[i] = 0;
			radii[i] = 0;
		}
		TruePredicate truePredicate;
		GiSTlist<GiSTentry*> list = node->Search(truePredicate);  // retrieve all the entries in this node
		
		double overlap = ((MTnode *)node)->Overlap();
		double totalOverlap = overlap;
		
		delete node;
		while (!list.IsEmpty()) {
			GiSTentry *entry = list.RemoveFront ();
			path.MakeChild (entry->Ptr());
			node = ReadNode (path);

			overlap = ((MTnode *)node)->Overlap();
			totalOverlap += overlap;

			pages[node->Level()]++;
			radii[node->Level()] += ((MTkey *) entry->Key())->MaxRadius();
			GiSTlist<GiSTentry*> newlist;
			if (!node->IsLeaf()) {
				newlist = node->Search(truePredicate);  // recurse to next level
			}
			while (!newlist.IsEmpty()) {
				list.Append (newlist.RemoveFront ());
			}
			path.MakeParent ();
			delete entry;
			delete node;
		}
		// output the results
		cout << "Level:\tPages:\tAverage_Radius:"<<endl;
		int totalPages = 1;  // for the root
		for (int i=maxLevel-1; i>=0; i--) {
			totalPages += pages[i];
			cout << i << ":\t" << pages[i] << "\t" << radii[i]/pages[i] << endl;
		}
		cout << "TotalPages:\t" << totalPages << endl;
		cout << "LeafPages:\t" << pages[0] << endl;
		cout << "TotalOverlap:\t" << (float)totalOverlap << endl;
		delete []radii;
		delete []pages;
	} else {
		delete node;
	}
}
开发者ID:jsc0218,项目名称:MxTree,代码行数:58,代码来源:MT.cpp

示例3: ReadNode

// append the subtree rooted at from to the node to, which is used in the "append" phase of the BulkLoad algorithm
void
MT::Append (MTnode *to, MTnode *from)
{
	GiSTlist<MTnode *> *oldList = new GiSTlist<MTnode *>;  // upper level nodes to append
	oldList->Append(from);
	GiSTlist<GiSTpath> pathList;
	pathList.Append (to->Path());
	MTnode *node = new MTnode, *newNode = NULL;
	MT *fromTree = (MT *) from->Tree();
	do {
		GiSTlist<MTnode *> *newList = new GiSTlist<MTnode *>;  // lower level nodes to append
		while (!oldList->IsEmpty()) {
			delete node;
			node = oldList->RemoveFront();
			GiSTpath path = pathList.RemoveFront ();
			newNode = (MTnode *) ReadNode (path);  // node to be appended
			for (int i=0; i<node->NumEntries(); i++) {
				MTentry *entry = (MTentry *) (*node)[i].Ptr()->Copy();
				if (node->Level() > 0) {  // if node isn't a leaf, we've to allocate its children
					GiSTpath nodePath = node->Path();
					nodePath.MakeChild (entry->Ptr());
					newList->Append((MTnode *) fromTree->ReadNode(nodePath));
					entry->SetPtr(Store()->Allocate());  // allocate its child in the inserted tree
					path.MakeChild (entry->Ptr());
					MTnode *childNode = (MTnode *) CreateNode ();
					childNode->Path() = path;
					childNode->SetTree(this);
					WriteNode (childNode);  // write the empty node
					delete childNode;
					pathList.Append (path);
					path.MakeParent ();
				}
				newNode->Insert(*entry);
				delete entry;
			}
			newNode->SetLevel(node->Level());
			WriteNode (newNode);  // write the node
			delete newNode;
		}
		delete oldList;
		oldList = newList;
	} while (node->Level() > 0);  // until we reach the leaves' level
	delete node;
	delete oldList;
}
开发者ID:jsc0218,项目名称:MxTree,代码行数:46,代码来源:BulkLoad.cpp

示例4:

GiSTnode* 
GiST::ChooseSubtree(GiSTpage page, const GiSTentry &entry, int level)
{
	GiSTnode *node;
	GiSTpath path;

	for(;;) {
		path.MakeChild(page);
		node=ReadNode(path);
		if(level==node->Level()||node->IsLeaf()) break;
		page=node->SearchMinPenalty(entry);
		delete node;
	}
	return node;
}
开发者ID:voidcycles,项目名称:m3,代码行数:15,代码来源:GiST.cpp

示例5: ReadNode

void 
GiST::DumpNode (ostream& os, GiSTpath path) const
{
	GiSTnode *node = ReadNode(path);
	node->Print(os);

	if (!node->IsLeaf()) {
		TruePredicate truePredicate;
		GiSTlist<GiSTentry*> list = node->Search(truePredicate);

		while (!list.IsEmpty()) {
			GiSTentry *e = list.RemoveFront();
			path.MakeChild(e->Ptr());
			DumpNode (os, path);
			path.MakeParent();
			delete e;
		}
	}
	delete node;
}
开发者ID:jsc0218,项目名称:MxTree,代码行数:20,代码来源:GiST.cpp

示例6: Path

GiSTlist<MTentry *>
MTnode::RangeSearch (const MTquery &query)
{
	GiSTlist<MTentry *> results;

	if (IsLeaf()) {
		for (int i=0; i<NumEntries(); i++) {
			MTentry *entry = (MTentry *) (*this)[i].Ptr()->Copy();
			MTquery *newQuery = (MTquery *) query.Copy();
			if (newQuery->Consistent(*entry)) {  // object qualifies
				entry->SetMaxRadius(newQuery->Grade());
				results.Append (entry);
			} else {
				delete entry;
			}
			delete newQuery;
		}
	} else {
		for (int i=0; i<NumEntries(); i++) {
			MTentry *entry = (MTentry *) (*this)[i].Ptr();
			MTquery *newQuery = (MTquery *) query.Copy();
			if (newQuery->Consistent(*entry)) {  // sub-tree included
				GiSTpath childPath = Path ();
				childPath.MakeChild (entry->Ptr());
				MTnode *childNode = (MTnode *) ((MT *)Tree())->ReadNode(childPath);
				GiSTlist<MTentry *> childResults = childNode->RangeSearch(*newQuery);  // recurse the search
				while (!childResults.IsEmpty()) {
					results.Append (childResults.RemoveFront());
				}
				delete childNode;
			}
			delete newQuery;
		}
	}

	return results;
}
开发者ID:jsc0218,项目名称:MxTree,代码行数:37,代码来源:MTnode.cpp

示例7: EntrySize


//.........这里部分代码省略.........
				topEntries2.Append (parentEntry);
			}
			subtree->Close();
			delete subtree->Store();  // it was created in tree->Open()
		}

		// build the super tree upon the parents
		MTentry **topEntrArr = new MTentry *[nSamples];  // array of the parent entries for each subtree
		char **subNameArr = new char *[nSamples];  // array of the subtrees names
		for (int i=0; i<nSamples; i++) {  // convert the lists into arrays
			topEntrArr[i] = topEntries2.RemoveFront ();
			subNameArr[i] = subtreeNames2.RemoveFront ();
		}
		assert (topEntries2.IsEmpty());
		assert (subtreeNames2.IsEmpty());
		sprintf (newName, "%s.0", name);
		BulkLoad (topEntrArr, nSamples, padFactor, newName);
		// attach each subtree to the leaves of the super tree
		GiSTpath path;
		path.MakeRoot ();
		MTnode *node = (MTnode *) ReadNode (path);
		GiSTlist<MTnode *> *oldList = new GiSTlist<MTnode *>;  // upper level nodes
		oldList->Append(node);
		int level = node->Level();
		while (level > 0) {  // build the leaves list for super tree
			GiSTlist<MTnode *> *newList = new GiSTlist<MTnode *>;  // lower level nodes
			while (!oldList->IsEmpty()) {
				node = oldList->RemoveFront();
				path = node->Path();
				node->SetLevel(node->Level() + minHeight);  // update level of the upper nodes of the super tree
				WriteNode (node);
				for (int i=0; i<node->NumEntries(); i++) {
					MTentry *entry = (MTentry *) (*node)[i].Ptr();
					path.MakeChild (entry->Ptr());
					newList->Append((MTnode *)ReadNode(path));
					path.MakeParent ();
				}
				delete node;
			}
			delete oldList;
			oldList = newList;
			level--;
		}
		while (!oldList->IsEmpty()) {  // attach each subtree to its leaf
			node = oldList->RemoveFront();  // retrieve next leaf (root of subtree)
			node->SetLevel(minHeight);  // update level of the root of the subtree
			path = node->Path();
			for (int i=0; i<node->NumEntries(); i++) {
				MTentry *entry = (MTentry *) (*node)[i].Ptr();
				path.MakeChild(Store()->Allocate());
				MTnode *newNode = (MTnode *) CreateNode ();
				newNode->Path() = path;
				entry->SetPtr(path.Page());
				path.MakeParent ();
				int j = 0;
				for (; entry->object() != topEntrArr[j]->object(); j++);  // search the position to append
				subtree->Open(subNameArr[j]);
				GiSTpath rootPath;
				rootPath.MakeRoot ();
				Append (newNode, (MTnode *)subtree->ReadNode(rootPath));  // append this subtree to the super tree
				subtree->Close();
				delete subtree->Store();  // it was created in tree->Open()
				delete newNode;
			}
			WriteNode (node);
			delete node;
开发者ID:jsc0218,项目名称:MxTree,代码行数:67,代码来源:BulkLoad.cpp


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