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

📄 hnsrtreeblock.cc

📁 R 树
💻 CC
字号:
/* * HnSRTreeBlock.cc * * DO NOT EDIT THIS FILE! * * This file is automatically generated by obj2ptr. * 1997/06/02 21:19:32 */#include "HnSRTreeBlock.hh"#include "HnSRTreeBlockObj.hh"/* * HnSRTreeBlock */const HnSRTreeBlock HnSRTreeBlock::null;HnSRTreeBlocknew_HnSRTreeBlock(off_t offset, const char *bytes, size_t size){	HnSRTreeBlockObj *_obj;	HnSRTreeBlock _ptr;	_obj = new HnSRTreeBlockObj(offset, bytes, size);	if(_obj->hasFailed())		return HnSRTreeBlock::null;	_ptr.assign(_obj);	return _ptr;}off_tHnSRTreeBlock::getOffset(void) const{	return getObject()->getOffset();}const char *HnSRTreeBlock::getBytes(void) const{	return getObject()->getBytes();}size_tHnSRTreeBlock::getSize(void) const{	return getObject()->getSize();}HnSRTreeBlock::TypeHnSRTreeBlock::getType(void) const{	return getObject()->getType();}HnBoolHnSRTreeBlock::isNode(void) const{	return getObject()->isNode();}HnBoolHnSRTreeBlock::isLeaf(void) const{	return getObject()->isLeaf();}HnBoolHnSRTreeBlock::isFree(void) const{	return getObject()->isFree();}/* * HnSRTreeBlockArrayObj */#include <stdlib.h>#include "HnString.hh"class HnSRTreeBlockArrayObj: public HnObject {private:	HnSRTreeBlock **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 */	HnSRTreeBlockArrayObj(void);	HnSRTreeBlockArrayObj(const HnSRTreeBlockArray &ptr);	~HnSRTreeBlockArrayObj(void);	/* clear, append, insert, and remove */	void clear(void);	void append(const HnSRTreeBlock &ptr);	void append(const HnSRTreeBlockArray &ptr);	void insert(const HnSRTreeBlock &ptr, int index);	HnSRTreeBlock remove(int index);	void set(const HnSRTreeBlock &ptr, int index);	void swap(int i, int j);	/* length and get */	int length(void) const { return len; }	HnSRTreeBlock &get(int i) const;	/* utilities */	HnBool equals(const HnSRTreeBlockArray &ptr) const;	int indexOf(const HnSRTreeBlock &ptr, int fromIndex) const;	HnString toString(void) const;};const int HnSRTreeBlockArrayObj::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;}voidHnSRTreeBlockArrayObj::ensureSize(int requiredSize){	int oldSize, newSize;	if((oldSize = size) >= requiredSize)		return;	if((newSize = oldSize) == 0)		newSize = initialSize;	while(newSize < requiredSize)		newSize *= 2;	array = (HnSRTreeBlock **)xrealloc(array, sizeof(HnSRTreeBlock *) * newSize);	size = newSize;}HnSRTreeBlockArrayObj::HnSRTreeBlockArrayObj(void){	initialize();}HnSRTreeBlockArrayObj::HnSRTreeBlockArrayObj(const HnSRTreeBlockArray &ptr){	initialize();	clear();	append(ptr);}HnSRTreeBlockArrayObj::~HnSRTreeBlockArrayObj(void){	dispose();}voidHnSRTreeBlockArrayObj::clear(void){	dispose();}voidHnSRTreeBlockArrayObj::append(const HnSRTreeBlock &ptr){	ensureSize(len + 1);	array[len] = new HnSRTreeBlock(ptr);	len ++;}voidHnSRTreeBlockArrayObj::append(const HnSRTreeBlockArray &ptr){	int i;	ensureSize(len + ptr.length());	for(i=0; i<ptr.length(); i++)		append(ptr[i]);}voidHnSRTreeBlockArrayObj::insert(const HnSRTreeBlock &ptr, int index){	if(index < 0 || index > len)		HnAbort("HnSRTreeBlockArrayObj::insert: "			"index is out of bounds.");	ensureSize(len + 1);	memmove(array + index + 1, array + index,		sizeof(HnSRTreeBlock *) * (len - index));	array[index] = new HnSRTreeBlock(ptr);	len ++;}HnSRTreeBlockHnSRTreeBlockArrayObj::remove(int index){	HnSRTreeBlock ptr = get(index);	if(index < 0 || index >= len)                HnAbort("HnSRTreeBlockArrayObj::remove: "			"index is out of bounds.");	delete array[index];	memmove(array + index, array + index + 1,		sizeof(HnSRTreeBlock *) * (len - index - 1));	len --;	return ptr;}voidHnSRTreeBlockArrayObj::set(const HnSRTreeBlock &ptr, int index){	if(index < 0 || index >= len)		HnAbort("HnSRTreeBlockArrayObj::set: "			"index is out of bounds.");	delete array[index];	array[index] = new HnSRTreeBlock(ptr);}voidHnSRTreeBlockArrayObj::swap(int i, int j){	if(i < 0 || i >= len || j < 0 || j >= len)		HnAbort("HnSRTreeBlockArrayObj::swap: index is out of bounds.");	HnSRTreeBlock *ptr = array[i];	array[i] = array[j];	array[j] = ptr;}HnSRTreeBlock &HnSRTreeBlockArrayObj::get(int i) const {	if(i < 0 || i >= len)		HnAbort("HnSRTreeBlockArrayObj::get: index is out of bounds.");	return *array[i];}HnBoolHnSRTreeBlockArrayObj::equals(const HnSRTreeBlockArray &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;}intHnSRTreeBlockArrayObj::indexOf(const HnSRTreeBlock &ptr, int fromIndex) const{	int i;	for(i=fromIndex; i<len; i++) {		if(array[i]->equals(ptr))			return i;	}	return -1;}HnStringHnSRTreeBlockArrayObj::toString(void) const{	HnString string;	string = "[ ";	for(int i=0; i<len; i++) {		if(i != 0)			string += ", ";		string += array[i]->toString();	}	string += " ]";	return string;}/* * HnSRTreeBlockArray */const HnSRTreeBlockArray HnSRTreeBlockArray::null;HnSRTreeBlockArraynew_HnSRTreeBlockArray(void){	HnSRTreeBlockArray ptr;        ptr.assign(new HnSRTreeBlockArrayObj());        return ptr;}HnSRTreeBlockArraynew_HnSRTreeBlockArray(const HnSRTreeBlockArray &value){	HnSRTreeBlockArray ptr;        if(value.isInvalid())                ptr.assign(NULL);        else                ptr.assign(new HnSRTreeBlockArrayObj(value));        return ptr;}voidHnSRTreeBlockArray::clear(void){	getObject()->clear();}voidHnSRTreeBlockArray::append(const HnSRTreeBlock &ptr){	getObject()->append(ptr);}voidHnSRTreeBlockArray::append(const HnSRTreeBlockArray &ptr){	getObject()->append(ptr);}voidHnSRTreeBlockArray::insert(const HnSRTreeBlock &ptr, int index){	getObject()->insert(ptr, index);}HnSRTreeBlockHnSRTreeBlockArray::remove(int index){	return getObject()->remove(index);}voidHnSRTreeBlockArray::set(const HnSRTreeBlock &ptr, int index){	getObject()->set(ptr, index);}voidHnSRTreeBlockArray::swap(int i, int j){	getObject()->swap(i, j);}intHnSRTreeBlockArray::length(void) const{	return getObject()->length();}HnSRTreeBlock &HnSRTreeBlockArray::get(int i) const{	return getObject()->get(i);}HnBoolHnSRTreeBlockArray::equals(const HnSRTreeBlockArray &ptr) const{	return getObject()->equals(ptr);}intHnSRTreeBlockArray::indexOf(const HnSRTreeBlock &ptr, int fromIndex) const{	return getObject()->indexOf(ptr, fromIndex);}HnStringHnSRTreeBlockArray::toString(void) const{	return getObject()->toString();}

⌨️ 快捷键说明

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