📄 hnsrtreestack.cc
字号:
/* * HnSRTreeStack.cc * * DO NOT EDIT THIS FILE! * * This file is automatically generated by obj2ptr. * 1997/06/02 21:19:34 */#include "HnSRTreeStack.hh"#include "HnSRTreeStackObj.hh"/* * HnSRTreeStack */const HnSRTreeStack HnSRTreeStack::null;HnSRTreeStacknew_HnSRTreeStack(void){ HnSRTreeStackObj *_obj; HnSRTreeStack _ptr; _obj = new HnSRTreeStackObj(); if(_obj->hasFailed()) return HnSRTreeStack::null; _ptr.assign(_obj); return _ptr;}voidHnSRTreeStack::push(const HnSRTreeNode &node, int cursor){ getObject()->push(node, cursor);}voidHnSRTreeStack::push(const HnSRTreeLeaf &leaf, int cursor){ getObject()->push(leaf, cursor);}voidHnSRTreeStack::push(const HnSRTreeNode &node){ getObject()->push(node);}voidHnSRTreeStack::push(const HnSRTreeLeaf &leaf){ getObject()->push(leaf);}voidHnSRTreeStack::pop(void){ getObject()->pop();}voidHnSRTreeStack::advance(void){ getObject()->advance();}intHnSRTreeStack::getDepth(void) const{ return getObject()->getDepth();}intHnSRTreeStack::getCursor(void) const{ return getObject()->getCursor();}HnBoolHnSRTreeStack::hasMore(void) const{ return getObject()->hasMore();}HnBoolHnSRTreeStack::isTopNode(void) const{ return getObject()->isTopNode();}HnBoolHnSRTreeStack::isTopLeaf(void) const{ return getObject()->isTopLeaf();}HnSRTreeNodeHnSRTreeStack::getTopNode(void) const{ return getObject()->getTopNode();}HnSRTreeLeafHnSRTreeStack::getTopLeaf(void) const{ return getObject()->getTopLeaf();}/* * HnSRTreeStackArrayObj */#include <stdlib.h>#include "HnString.hh"class HnSRTreeStackArrayObj: public HnObject {private: HnSRTreeStack **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 */ HnSRTreeStackArrayObj(void); HnSRTreeStackArrayObj(const HnSRTreeStackArray &ptr); ~HnSRTreeStackArrayObj(void); /* clear, append, insert, and remove */ void clear(void); void append(const HnSRTreeStack &ptr); void append(const HnSRTreeStackArray &ptr); void insert(const HnSRTreeStack &ptr, int index); HnSRTreeStack remove(int index); void set(const HnSRTreeStack &ptr, int index); void swap(int i, int j); /* length and get */ int length(void) const { return len; } HnSRTreeStack &get(int i) const; /* utilities */ HnBool equals(const HnSRTreeStackArray &ptr) const; int indexOf(const HnSRTreeStack &ptr, int fromIndex) const; HnString toString(void) const;};const int HnSRTreeStackArrayObj::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;}voidHnSRTreeStackArrayObj::ensureSize(int requiredSize){ int oldSize, newSize; if((oldSize = size) >= requiredSize) return; if((newSize = oldSize) == 0) newSize = initialSize; while(newSize < requiredSize) newSize *= 2; array = (HnSRTreeStack **)xrealloc(array, sizeof(HnSRTreeStack *) * newSize); size = newSize;}HnSRTreeStackArrayObj::HnSRTreeStackArrayObj(void){ initialize();}HnSRTreeStackArrayObj::HnSRTreeStackArrayObj(const HnSRTreeStackArray &ptr){ initialize(); clear(); append(ptr);}HnSRTreeStackArrayObj::~HnSRTreeStackArrayObj(void){ dispose();}voidHnSRTreeStackArrayObj::clear(void){ dispose();}voidHnSRTreeStackArrayObj::append(const HnSRTreeStack &ptr){ ensureSize(len + 1); array[len] = new HnSRTreeStack(ptr); len ++;}voidHnSRTreeStackArrayObj::append(const HnSRTreeStackArray &ptr){ int i; ensureSize(len + ptr.length()); for(i=0; i<ptr.length(); i++) append(ptr[i]);}voidHnSRTreeStackArrayObj::insert(const HnSRTreeStack &ptr, int index){ if(index < 0 || index > len) HnAbort("HnSRTreeStackArrayObj::insert: " "index is out of bounds."); ensureSize(len + 1); memmove(array + index + 1, array + index, sizeof(HnSRTreeStack *) * (len - index)); array[index] = new HnSRTreeStack(ptr); len ++;}HnSRTreeStackHnSRTreeStackArrayObj::remove(int index){ HnSRTreeStack ptr = get(index); if(index < 0 || index >= len) HnAbort("HnSRTreeStackArrayObj::remove: " "index is out of bounds."); delete array[index]; memmove(array + index, array + index + 1, sizeof(HnSRTreeStack *) * (len - index - 1)); len --; return ptr;}voidHnSRTreeStackArrayObj::set(const HnSRTreeStack &ptr, int index){ if(index < 0 || index >= len) HnAbort("HnSRTreeStackArrayObj::set: " "index is out of bounds."); delete array[index]; array[index] = new HnSRTreeStack(ptr);}voidHnSRTreeStackArrayObj::swap(int i, int j){ if(i < 0 || i >= len || j < 0 || j >= len) HnAbort("HnSRTreeStackArrayObj::swap: index is out of bounds."); HnSRTreeStack *ptr = array[i]; array[i] = array[j]; array[j] = ptr;}HnSRTreeStack &HnSRTreeStackArrayObj::get(int i) const { if(i < 0 || i >= len) HnAbort("HnSRTreeStackArrayObj::get: index is out of bounds."); return *array[i];}HnBoolHnSRTreeStackArrayObj::equals(const HnSRTreeStackArray &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;}intHnSRTreeStackArrayObj::indexOf(const HnSRTreeStack &ptr, int fromIndex) const{ int i; for(i=fromIndex; i<len; i++) { if(array[i]->equals(ptr)) return i; } return -1;}HnStringHnSRTreeStackArrayObj::toString(void) const{ HnString string; string = "[ "; for(int i=0; i<len; i++) { if(i != 0) string += ", "; string += array[i]->toString(); } string += " ]"; return string;}/* * HnSRTreeStackArray */const HnSRTreeStackArray HnSRTreeStackArray::null;HnSRTreeStackArraynew_HnSRTreeStackArray(void){ HnSRTreeStackArray ptr; ptr.assign(new HnSRTreeStackArrayObj()); return ptr;}HnSRTreeStackArraynew_HnSRTreeStackArray(const HnSRTreeStackArray &value){ HnSRTreeStackArray ptr; if(value.isInvalid()) ptr.assign(NULL); else ptr.assign(new HnSRTreeStackArrayObj(value)); return ptr;}voidHnSRTreeStackArray::clear(void){ getObject()->clear();}voidHnSRTreeStackArray::append(const HnSRTreeStack &ptr){ getObject()->append(ptr);}voidHnSRTreeStackArray::append(const HnSRTreeStackArray &ptr){ getObject()->append(ptr);}voidHnSRTreeStackArray::insert(const HnSRTreeStack &ptr, int index){ getObject()->insert(ptr, index);}HnSRTreeStackHnSRTreeStackArray::remove(int index){ return getObject()->remove(index);}voidHnSRTreeStackArray::set(const HnSRTreeStack &ptr, int index){ getObject()->set(ptr, index);}voidHnSRTreeStackArray::swap(int i, int j){ getObject()->swap(i, j);}intHnSRTreeStackArray::length(void) const{ return getObject()->length();}HnSRTreeStack &HnSRTreeStackArray::get(int i) const{ return getObject()->get(i);}HnBoolHnSRTreeStackArray::equals(const HnSRTreeStackArray &ptr) const{ return getObject()->equals(ptr);}intHnSRTreeStackArray::indexOf(const HnSRTreeStack &ptr, int fromIndex) const{ return getObject()->indexOf(ptr, fromIndex);}HnStringHnSRTreeStackArray::toString(void) const{ return getObject()->toString();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -