⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hnsrtreenode.cc

📁 R 树
💻 CC
字号:
/* * HnSRTreeNode.cc * * DO NOT EDIT THIS FILE! * * This file is automatically generated by obj2ptr. * 1997/06/02 21:19:33 */#include "HnSRTreeNode.hh"#include "HnSRTreeNodeObj.hh"/* * HnSRTreeNode */const HnSRTreeNode HnSRTreeNode::null;HnSRTreeNodenew_HnSRTreeNode(int dimension, int blockSize, off_t offset){	HnSRTreeNodeObj *_obj;	HnSRTreeNode _ptr;	_obj = new HnSRTreeNodeObj(dimension, blockSize, offset);	if(_obj->hasFailed())		return HnSRTreeNode::null;	_ptr.assign(_obj);	return _ptr;}HnSRTreeNodenew_HnSRTreeNode(int dimension, const HnSRTreeBlock &block){	HnSRTreeNodeObj *_obj;	HnSRTreeNode _ptr;	_obj = new HnSRTreeNodeObj(dimension, block);	if(_obj->hasFailed())		return HnSRTreeNode::null;	_ptr.assign(_obj);	return _ptr;}voidHnSRTreeNode::append(const HnSRTreeCore &core, const HnRect &rect, off_t offset){	getObject()->append(core, rect, offset);}voidHnSRTreeNode::remove(int index){	getObject()->remove(index);}voidHnSRTreeNode::setElementAt(const HnSRTreeCore &core, const HnRect &rect, off_t offset, int index){	getObject()->setElementAt(core, rect, offset, index);}voidHnSRTreeNode::setCoreAt(const HnSRTreeCore &core, int index){	getObject()->setCoreAt(core, index);}voidHnSRTreeNode::setBoundingRectAt(const HnRect &rect, int index){	getObject()->setBoundingRectAt(rect, index);}intHnSRTreeNode::getDimension(void) const{	return getObject()->getDimension();}intHnSRTreeNode::getBlockSize(void) const{	return getObject()->getBlockSize();}off_tHnSRTreeNode::getOffset(void) const{	return getObject()->getOffset();}intHnSRTreeNode::getCount(void) const{	return getObject()->getCount();}size_tHnSRTreeNode::getSize(void) const{	return getObject()->getSize();}HnBoolHnSRTreeNode::isFull(void) const{	return getObject()->isFull();}HnSRTreeCoreHnSRTreeNode::getCore(void) const{	return getObject()->getCore();}HnRectHnSRTreeNode::getBoundingRect(void) const{	return getObject()->getBoundingRect();}HnSRTreeCoreHnSRTreeNode::getCoreAt(int index) const{	return getObject()->getCoreAt(index);}HnRectHnSRTreeNode::getRectAt(int index) const{	return getObject()->getRectAt(index);}off_tHnSRTreeNode::getOffsetAt(int index) const{	return getObject()->getOffsetAt(index);}HnSRTreeBlockHnSRTreeNode::toBlock(void) const{	return getObject()->toBlock();}HnStringHnSRTreeNode::toString(void) const {	if(isInvalid())		return "HnSRTreeNode::null";    	else		return getObject()->toString();}intHnSRTreeNode::getMaxCount(int dimension, int blockSize){	return HnSRTreeNodeObj::getMaxCount(dimension, blockSize);}/* * HnSRTreeNodeArrayObj */#include <stdlib.h>#include "HnString.hh"class HnSRTreeNodeArrayObj: public HnObject {private:	HnSRTreeNode **array;	int len;	int size;	static const int initialSize;	void initialize(void) {		array = NULL;		len = 0;		size = 0;	}	void dispose(void) {		if(array != NULL) {			int i;			for(i=0; i<len; i++)				delete array[i];			free(array);		}		array = NULL;		len = 0;		size = 0;	}	void ensureSize(int requiredSize);public:	/* constructor and destructor */	HnSRTreeNodeArrayObj(void);	HnSRTreeNodeArrayObj(const HnSRTreeNodeArray &ptr);	~HnSRTreeNodeArrayObj(void);	/* clear, append, insert, and remove */	void clear(void);	void append(const HnSRTreeNode &ptr);	void append(const HnSRTreeNodeArray &ptr);	void insert(const HnSRTreeNode &ptr, int index);	HnSRTreeNode remove(int index);	void set(const HnSRTreeNode &ptr, int index);	void swap(int i, int j);	/* length and get */	int length(void) const { return len; }	HnSRTreeNode &get(int i) const;	/* utilities */	HnBool equals(const HnSRTreeNodeArray &ptr) const;	int indexOf(const HnSRTreeNode &ptr, int fromIndex) const;	HnString toString(void) const;};const int HnSRTreeNodeArrayObj::initialSize = 4;static void *xrealloc(void *ptr, size_t size){        if(ptr == NULL) {                if((ptr = malloc(size)) == NULL)                        HnSysError("malloc");        }        else {                if((ptr = realloc(ptr, size)) == NULL)                        HnSysError("realloc");        }        return ptr;}voidHnSRTreeNodeArrayObj::ensureSize(int requiredSize){	int oldSize, newSize;	if((oldSize = size) >= requiredSize)		return;	if((newSize = oldSize) == 0)		newSize = initialSize;	while(newSize < requiredSize)		newSize *= 2;	array = (HnSRTreeNode **)xrealloc(array, sizeof(HnSRTreeNode *) * newSize);	size = newSize;}HnSRTreeNodeArrayObj::HnSRTreeNodeArrayObj(void){	initialize();}HnSRTreeNodeArrayObj::HnSRTreeNodeArrayObj(const HnSRTreeNodeArray &ptr){	initialize();	clear();	append(ptr);}HnSRTreeNodeArrayObj::~HnSRTreeNodeArrayObj(void){	dispose();}voidHnSRTreeNodeArrayObj::clear(void){	dispose();}voidHnSRTreeNodeArrayObj::append(const HnSRTreeNode &ptr){	ensureSize(len + 1);	array[len] = new HnSRTreeNode(ptr);	len ++;}voidHnSRTreeNodeArrayObj::append(const HnSRTreeNodeArray &ptr){	int i;	ensureSize(len + ptr.length());	for(i=0; i<ptr.length(); i++)		append(ptr[i]);}voidHnSRTreeNodeArrayObj::insert(const HnSRTreeNode &ptr, int index){	if(index < 0 || index > len)		HnAbort("HnSRTreeNodeArrayObj::insert: "			"index is out of bounds.");	ensureSize(len + 1);	memmove(array + index + 1, array + index,		sizeof(HnSRTreeNode *) * (len - index));	array[index] = new HnSRTreeNode(ptr);	len ++;}HnSRTreeNodeHnSRTreeNodeArrayObj::remove(int index){	HnSRTreeNode ptr = get(index);	if(index < 0 || index >= len)                HnAbort("HnSRTreeNodeArrayObj::remove: "			"index is out of bounds.");	delete array[index];	memmove(array + index, array + index + 1,		sizeof(HnSRTreeNode *) * (len - index - 1));	len --;	return ptr;}voidHnSRTreeNodeArrayObj::set(const HnSRTreeNode &ptr, int index){	if(index < 0 || index >= len)		HnAbort("HnSRTreeNodeArrayObj::set: "			"index is out of bounds.");	delete array[index];	array[index] = new HnSRTreeNode(ptr);}voidHnSRTreeNodeArrayObj::swap(int i, int j){	if(i < 0 || i >= len || j < 0 || j >= len)		HnAbort("HnSRTreeNodeArrayObj::swap: index is out of bounds.");	HnSRTreeNode *ptr = array[i];	array[i] = array[j];	array[j] = ptr;}HnSRTreeNode &HnSRTreeNodeArrayObj::get(int i) const {	if(i < 0 || i >= len)		HnAbort("HnSRTreeNodeArrayObj::get: index is out of bounds.");	return *array[i];}HnBoolHnSRTreeNodeArrayObj::equals(const HnSRTreeNodeArray &ptr) const {	int i;	if(len != ptr.length())		return HnFALSE;	for(i=0; i<len; i++) {		if(!array[i]->equals(ptr[i]))			return HnFALSE;	}	return HnTRUE;}intHnSRTreeNodeArrayObj::indexOf(const HnSRTreeNode &ptr, int fromIndex) const{	int i;	for(i=fromIndex; i<len; i++) {		if(array[i]->equals(ptr))			return i;	}	return -1;}HnStringHnSRTreeNodeArrayObj::toString(void) const{	HnString string;	string = "[ ";	for(int i=0; i<len; i++) {		if(i != 0)			string += ", ";		string += array[i]->toString();	}	string += " ]";	return string;}/* * HnSRTreeNodeArray */const HnSRTreeNodeArray HnSRTreeNodeArray::null;HnSRTreeNodeArraynew_HnSRTreeNodeArray(void){	HnSRTreeNodeArray ptr;        ptr.assign(new HnSRTreeNodeArrayObj());        return ptr;}HnSRTreeNodeArraynew_HnSRTreeNodeArray(const HnSRTreeNodeArray &value){	HnSRTreeNodeArray ptr;        if(value.isInvalid())                ptr.assign(NULL);        else                ptr.assign(new HnSRTreeNodeArrayObj(value));        return ptr;}voidHnSRTreeNodeArray::clear(void){	getObject()->clear();}voidHnSRTreeNodeArray::append(const HnSRTreeNode &ptr){	getObject()->append(ptr);}voidHnSRTreeNodeArray::append(const HnSRTreeNodeArray &ptr){	getObject()->append(ptr);}voidHnSRTreeNodeArray::insert(const HnSRTreeNode &ptr, int index){	getObject()->insert(ptr, index);}HnSRTreeNodeHnSRTreeNodeArray::remove(int index){	return getObject()->remove(index);}voidHnSRTreeNodeArray::set(const HnSRTreeNode &ptr, int index){	getObject()->set(ptr, index);}voidHnSRTreeNodeArray::swap(int i, int j){	getObject()->swap(i, j);}intHnSRTreeNodeArray::length(void) const{	return getObject()->length();}HnSRTreeNode &HnSRTreeNodeArray::get(int i) const{	return getObject()->get(i);}HnBoolHnSRTreeNodeArray::equals(const HnSRTreeNodeArray &ptr) const{	return getObject()->equals(ptr);}intHnSRTreeNodeArray::indexOf(const HnSRTreeNode &ptr, int fromIndex) const{	return getObject()->indexOf(ptr, fromIndex);}HnStringHnSRTreeNodeArray::toString(void) const{	return getObject()->toString();}

⌨️ 快捷键说明

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