📄 hnsrtreeleaf.cc
字号:
/* * HnSRTreeLeaf.cc * * DO NOT EDIT THIS FILE! * * This file is automatically generated by obj2ptr. * 1997/06/02 21:19:33 */#include "HnSRTreeLeaf.hh"#include "HnSRTreeLeafObj.hh"/* * HnSRTreeLeaf */const HnSRTreeLeaf HnSRTreeLeaf::null;HnSRTreeLeafnew_HnSRTreeLeaf(int dimension, int dataSize, int blockSize, off_t offset){ HnSRTreeLeafObj *_obj; HnSRTreeLeaf _ptr; _obj = new HnSRTreeLeafObj(dimension, dataSize, blockSize, offset); if(_obj->hasFailed()) return HnSRTreeLeaf::null; _ptr.assign(_obj); return _ptr;}HnSRTreeLeafnew_HnSRTreeLeaf(int dimension, int dataSize, const HnSRTreeBlock &block){ HnSRTreeLeafObj *_obj; HnSRTreeLeaf _ptr; _obj = new HnSRTreeLeafObj(dimension, dataSize, block); if(_obj->hasFailed()) return HnSRTreeLeaf::null; _ptr.assign(_obj); return _ptr;}voidHnSRTreeLeaf::append(const HnPoint &point, const HnData &data){ getObject()->append(point, data);}voidHnSRTreeLeaf::remove(int index){ getObject()->remove(index);}intHnSRTreeLeaf::getDimension(void) const{ return getObject()->getDimension();}intHnSRTreeLeaf::getDataSize(void) const{ return getObject()->getDataSize();}intHnSRTreeLeaf::getBlockSize(void) const{ return getObject()->getBlockSize();}off_tHnSRTreeLeaf::getOffset(void) const{ return getObject()->getOffset();}intHnSRTreeLeaf::getCount(void) const{ return getObject()->getCount();}size_tHnSRTreeLeaf::getSize(void) const{ return getObject()->getSize();}HnBoolHnSRTreeLeaf::isFull(void) const{ return getObject()->isFull();}HnSRTreeCoreHnSRTreeLeaf::getCore(void) const{ return getObject()->getCore();}HnRectHnSRTreeLeaf::getBoundingRect(void) const{ return getObject()->getBoundingRect();}HnPointHnSRTreeLeaf::getPointAt(int index) const{ return getObject()->getPointAt(index);}HnDataHnSRTreeLeaf::getDataAt(int index) const{ return getObject()->getDataAt(index);}HnSRTreeBlockHnSRTreeLeaf::toBlock(void) const{ return getObject()->toBlock();}HnStringHnSRTreeLeaf::toString(void) const { if(isInvalid()) return "HnSRTreeLeaf::null"; else return getObject()->toString();}intHnSRTreeLeaf::getMaxCount(int dimension, int dataSize, int blockSize){ return HnSRTreeLeafObj::getMaxCount(dimension, dataSize, blockSize);}/* * HnSRTreeLeafArrayObj */#include <stdlib.h>#include "HnString.hh"class HnSRTreeLeafArrayObj: public HnObject {private: HnSRTreeLeaf **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 */ HnSRTreeLeafArrayObj(void); HnSRTreeLeafArrayObj(const HnSRTreeLeafArray &ptr); ~HnSRTreeLeafArrayObj(void); /* clear, append, insert, and remove */ void clear(void); void append(const HnSRTreeLeaf &ptr); void append(const HnSRTreeLeafArray &ptr); void insert(const HnSRTreeLeaf &ptr, int index); HnSRTreeLeaf remove(int index); void set(const HnSRTreeLeaf &ptr, int index); void swap(int i, int j); /* length and get */ int length(void) const { return len; } HnSRTreeLeaf &get(int i) const; /* utilities */ HnBool equals(const HnSRTreeLeafArray &ptr) const; int indexOf(const HnSRTreeLeaf &ptr, int fromIndex) const; HnString toString(void) const;};const int HnSRTreeLeafArrayObj::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;}voidHnSRTreeLeafArrayObj::ensureSize(int requiredSize){ int oldSize, newSize; if((oldSize = size) >= requiredSize) return; if((newSize = oldSize) == 0) newSize = initialSize; while(newSize < requiredSize) newSize *= 2; array = (HnSRTreeLeaf **)xrealloc(array, sizeof(HnSRTreeLeaf *) * newSize); size = newSize;}HnSRTreeLeafArrayObj::HnSRTreeLeafArrayObj(void){ initialize();}HnSRTreeLeafArrayObj::HnSRTreeLeafArrayObj(const HnSRTreeLeafArray &ptr){ initialize(); clear(); append(ptr);}HnSRTreeLeafArrayObj::~HnSRTreeLeafArrayObj(void){ dispose();}voidHnSRTreeLeafArrayObj::clear(void){ dispose();}voidHnSRTreeLeafArrayObj::append(const HnSRTreeLeaf &ptr){ ensureSize(len + 1); array[len] = new HnSRTreeLeaf(ptr); len ++;}voidHnSRTreeLeafArrayObj::append(const HnSRTreeLeafArray &ptr){ int i; ensureSize(len + ptr.length()); for(i=0; i<ptr.length(); i++) append(ptr[i]);}voidHnSRTreeLeafArrayObj::insert(const HnSRTreeLeaf &ptr, int index){ if(index < 0 || index > len) HnAbort("HnSRTreeLeafArrayObj::insert: " "index is out of bounds."); ensureSize(len + 1); memmove(array + index + 1, array + index, sizeof(HnSRTreeLeaf *) * (len - index)); array[index] = new HnSRTreeLeaf(ptr); len ++;}HnSRTreeLeafHnSRTreeLeafArrayObj::remove(int index){ HnSRTreeLeaf ptr = get(index); if(index < 0 || index >= len) HnAbort("HnSRTreeLeafArrayObj::remove: " "index is out of bounds."); delete array[index]; memmove(array + index, array + index + 1, sizeof(HnSRTreeLeaf *) * (len - index - 1)); len --; return ptr;}voidHnSRTreeLeafArrayObj::set(const HnSRTreeLeaf &ptr, int index){ if(index < 0 || index >= len) HnAbort("HnSRTreeLeafArrayObj::set: " "index is out of bounds."); delete array[index]; array[index] = new HnSRTreeLeaf(ptr);}voidHnSRTreeLeafArrayObj::swap(int i, int j){ if(i < 0 || i >= len || j < 0 || j >= len) HnAbort("HnSRTreeLeafArrayObj::swap: index is out of bounds."); HnSRTreeLeaf *ptr = array[i]; array[i] = array[j]; array[j] = ptr;}HnSRTreeLeaf &HnSRTreeLeafArrayObj::get(int i) const { if(i < 0 || i >= len) HnAbort("HnSRTreeLeafArrayObj::get: index is out of bounds."); return *array[i];}HnBoolHnSRTreeLeafArrayObj::equals(const HnSRTreeLeafArray &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;}intHnSRTreeLeafArrayObj::indexOf(const HnSRTreeLeaf &ptr, int fromIndex) const{ int i; for(i=fromIndex; i<len; i++) { if(array[i]->equals(ptr)) return i; } return -1;}HnStringHnSRTreeLeafArrayObj::toString(void) const{ HnString string; string = "[ "; for(int i=0; i<len; i++) { if(i != 0) string += ", "; string += array[i]->toString(); } string += " ]"; return string;}/* * HnSRTreeLeafArray */const HnSRTreeLeafArray HnSRTreeLeafArray::null;HnSRTreeLeafArraynew_HnSRTreeLeafArray(void){ HnSRTreeLeafArray ptr; ptr.assign(new HnSRTreeLeafArrayObj()); return ptr;}HnSRTreeLeafArraynew_HnSRTreeLeafArray(const HnSRTreeLeafArray &value){ HnSRTreeLeafArray ptr; if(value.isInvalid()) ptr.assign(NULL); else ptr.assign(new HnSRTreeLeafArrayObj(value)); return ptr;}voidHnSRTreeLeafArray::clear(void){ getObject()->clear();}voidHnSRTreeLeafArray::append(const HnSRTreeLeaf &ptr){ getObject()->append(ptr);}voidHnSRTreeLeafArray::append(const HnSRTreeLeafArray &ptr){ getObject()->append(ptr);}voidHnSRTreeLeafArray::insert(const HnSRTreeLeaf &ptr, int index){ getObject()->insert(ptr, index);}HnSRTreeLeafHnSRTreeLeafArray::remove(int index){ return getObject()->remove(index);}voidHnSRTreeLeafArray::set(const HnSRTreeLeaf &ptr, int index){ getObject()->set(ptr, index);}voidHnSRTreeLeafArray::swap(int i, int j){ getObject()->swap(i, j);}intHnSRTreeLeafArray::length(void) const{ return getObject()->length();}HnSRTreeLeaf &HnSRTreeLeafArray::get(int i) const{ return getObject()->get(i);}HnBoolHnSRTreeLeafArray::equals(const HnSRTreeLeafArray &ptr) const{ return getObject()->equals(ptr);}intHnSRTreeLeafArray::indexOf(const HnSRTreeLeaf &ptr, int fromIndex) const{ return getObject()->indexOf(ptr, fromIndex);}HnStringHnSRTreeLeafArray::toString(void) const{ return getObject()->toString();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -