📄 hnsrtreefile.cc
字号:
/* * HnSRTreeFile.cc * * DO NOT EDIT THIS FILE! * * This file is automatically generated by obj2ptr. * 1997/06/02 21:19:34 */#include "HnSRTreeFile.hh"#include "HnSRTreeFileObj.hh"/* * HnSRTreeFile */const HnSRTreeFile HnSRTreeFile::null;HnSRTreeFilenew_HnSRTreeFile(const char *path, int dimension, int dataSize, int blockSize, int splitFactor, int reinsertFactor){ HnSRTreeFileObj *_obj; HnSRTreeFile _ptr; _obj = new HnSRTreeFileObj(path, dimension, dataSize, blockSize, splitFactor, reinsertFactor); if(_obj->hasFailed()) return HnSRTreeFile::null; _ptr.assign(_obj); return _ptr;}HnSRTreeFilenew_HnSRTreeFile(const char *path, int dimension, int dataSize, int blockSize, int splitFactor, int reinsertFactor, HnPointArray &points, HnDataArray &values, HnBool debug){ HnSRTreeFileObj *_obj; HnSRTreeFile _ptr; _obj = new HnSRTreeFileObj(path, dimension, dataSize, blockSize, splitFactor, reinsertFactor, points, values, debug); if(_obj->hasFailed()) return HnSRTreeFile::null; _ptr.assign(_obj); return _ptr;}HnSRTreeFilenew_HnSRTreeFile(const char *path, const char *mode){ HnSRTreeFileObj *_obj; HnSRTreeFile _ptr; _obj = new HnSRTreeFileObj(path, mode); if(_obj->hasFailed()) return HnSRTreeFile::null; _ptr.assign(_obj); return _ptr;}intHnSRTreeFile::getDimension(void) const{ return getObject()->getDimension();}intHnSRTreeFile::getBlockSize(void) const{ return getObject()->getBlockSize();}intHnSRTreeFile::getDataSize(void) const{ return getObject()->getDataSize();}intHnSRTreeFile::getHeight(void) const{ return getObject()->getHeight();}voidHnSRTreeFile::store(const HnPoint &point, const HnData &data){ getObject()->store(point, data);}voidHnSRTreeFile::remove(const HnPoint &point, const HnData &data){ getObject()->remove(point, data);}voidHnSRTreeFile::close(void){ getObject()->close();}voidHnSRTreeFile::getFirst(HnPoint *point_return, HnData *data_return){ getObject()->getFirst(point_return, data_return);}voidHnSRTreeFile::getFirst(const HnRect &rect, HnPoint *point_return, HnData *data_return){ getObject()->getFirst(rect, point_return, data_return);}voidHnSRTreeFile::getNext(HnPoint *point_return, HnData *data_return){ getObject()->getNext(point_return, data_return);}voidHnSRTreeFile::getNeighbors(const HnPoint &point, int maxCount, HnPointArray *points_return, HnDataArray *values_return){ getObject()->getNeighbors(point, maxCount, points_return, values_return);}voidHnSRTreeFile::check(void){ getObject()->check();}voidHnSRTreeFile::print(void){ getObject()->print();}voidHnSRTreeFile::setDebug(HnBool flag){ getObject()->setDebug(flag);}/* * HnSRTreeFileArrayObj */#include <stdlib.h>#include "HnString.hh"class HnSRTreeFileArrayObj: public HnObject {private: HnSRTreeFile **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 */ HnSRTreeFileArrayObj(void); HnSRTreeFileArrayObj(const HnSRTreeFileArray &ptr); ~HnSRTreeFileArrayObj(void); /* clear, append, insert, and remove */ void clear(void); void append(const HnSRTreeFile &ptr); void append(const HnSRTreeFileArray &ptr); void insert(const HnSRTreeFile &ptr, int index); HnSRTreeFile remove(int index); void set(const HnSRTreeFile &ptr, int index); void swap(int i, int j); /* length and get */ int length(void) const { return len; } HnSRTreeFile &get(int i) const; /* utilities */ HnBool equals(const HnSRTreeFileArray &ptr) const; int indexOf(const HnSRTreeFile &ptr, int fromIndex) const; HnString toString(void) const;};const int HnSRTreeFileArrayObj::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;}voidHnSRTreeFileArrayObj::ensureSize(int requiredSize){ int oldSize, newSize; if((oldSize = size) >= requiredSize) return; if((newSize = oldSize) == 0) newSize = initialSize; while(newSize < requiredSize) newSize *= 2; array = (HnSRTreeFile **)xrealloc(array, sizeof(HnSRTreeFile *) * newSize); size = newSize;}HnSRTreeFileArrayObj::HnSRTreeFileArrayObj(void){ initialize();}HnSRTreeFileArrayObj::HnSRTreeFileArrayObj(const HnSRTreeFileArray &ptr){ initialize(); clear(); append(ptr);}HnSRTreeFileArrayObj::~HnSRTreeFileArrayObj(void){ dispose();}voidHnSRTreeFileArrayObj::clear(void){ dispose();}voidHnSRTreeFileArrayObj::append(const HnSRTreeFile &ptr){ ensureSize(len + 1); array[len] = new HnSRTreeFile(ptr); len ++;}voidHnSRTreeFileArrayObj::append(const HnSRTreeFileArray &ptr){ int i; ensureSize(len + ptr.length()); for(i=0; i<ptr.length(); i++) append(ptr[i]);}voidHnSRTreeFileArrayObj::insert(const HnSRTreeFile &ptr, int index){ if(index < 0 || index > len) HnAbort("HnSRTreeFileArrayObj::insert: " "index is out of bounds."); ensureSize(len + 1); memmove(array + index + 1, array + index, sizeof(HnSRTreeFile *) * (len - index)); array[index] = new HnSRTreeFile(ptr); len ++;}HnSRTreeFileHnSRTreeFileArrayObj::remove(int index){ HnSRTreeFile ptr = get(index); if(index < 0 || index >= len) HnAbort("HnSRTreeFileArrayObj::remove: " "index is out of bounds."); delete array[index]; memmove(array + index, array + index + 1, sizeof(HnSRTreeFile *) * (len - index - 1)); len --; return ptr;}voidHnSRTreeFileArrayObj::set(const HnSRTreeFile &ptr, int index){ if(index < 0 || index >= len) HnAbort("HnSRTreeFileArrayObj::set: " "index is out of bounds."); delete array[index]; array[index] = new HnSRTreeFile(ptr);}voidHnSRTreeFileArrayObj::swap(int i, int j){ if(i < 0 || i >= len || j < 0 || j >= len) HnAbort("HnSRTreeFileArrayObj::swap: index is out of bounds."); HnSRTreeFile *ptr = array[i]; array[i] = array[j]; array[j] = ptr;}HnSRTreeFile &HnSRTreeFileArrayObj::get(int i) const { if(i < 0 || i >= len) HnAbort("HnSRTreeFileArrayObj::get: index is out of bounds."); return *array[i];}HnBoolHnSRTreeFileArrayObj::equals(const HnSRTreeFileArray &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;}intHnSRTreeFileArrayObj::indexOf(const HnSRTreeFile &ptr, int fromIndex) const{ int i; for(i=fromIndex; i<len; i++) { if(array[i]->equals(ptr)) return i; } return -1;}HnStringHnSRTreeFileArrayObj::toString(void) const{ HnString string; string = "[ "; for(int i=0; i<len; i++) { if(i != 0) string += ", "; string += array[i]->toString(); } string += " ]"; return string;}/* * HnSRTreeFileArray */const HnSRTreeFileArray HnSRTreeFileArray::null;HnSRTreeFileArraynew_HnSRTreeFileArray(void){ HnSRTreeFileArray ptr; ptr.assign(new HnSRTreeFileArrayObj()); return ptr;}HnSRTreeFileArraynew_HnSRTreeFileArray(const HnSRTreeFileArray &value){ HnSRTreeFileArray ptr; if(value.isInvalid()) ptr.assign(NULL); else ptr.assign(new HnSRTreeFileArrayObj(value)); return ptr;}voidHnSRTreeFileArray::clear(void){ getObject()->clear();}voidHnSRTreeFileArray::append(const HnSRTreeFile &ptr){ getObject()->append(ptr);}voidHnSRTreeFileArray::append(const HnSRTreeFileArray &ptr){ getObject()->append(ptr);}voidHnSRTreeFileArray::insert(const HnSRTreeFile &ptr, int index){ getObject()->insert(ptr, index);}HnSRTreeFileHnSRTreeFileArray::remove(int index){ return getObject()->remove(index);}voidHnSRTreeFileArray::set(const HnSRTreeFile &ptr, int index){ getObject()->set(ptr, index);}voidHnSRTreeFileArray::swap(int i, int j){ getObject()->swap(i, j);}intHnSRTreeFileArray::length(void) const{ return getObject()->length();}HnSRTreeFile &HnSRTreeFileArray::get(int i) const{ return getObject()->get(i);}HnBoolHnSRTreeFileArray::equals(const HnSRTreeFileArray &ptr) const{ return getObject()->equals(ptr);}intHnSRTreeFileArray::indexOf(const HnSRTreeFile &ptr, int fromIndex) const{ return getObject()->indexOf(ptr, fromIndex);}HnStringHnSRTreeFileArray::toString(void) const{ return getObject()->toString();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -