X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Fstructures%2Famorph.h;h=6d817e8aeb4ab93320fc0788a333815b5df5ccb2;hb=8995892763d06d6cf95265ac2c7e238092058c26;hp=d2104c700e26179087bd2787f80dcbda6a996c79;hpb=457b128b77b5b4a0b7dd3094de543de2ce1477ad;p=feisty_meow.git diff --git a/nucleus/library/structures/amorph.h b/nucleus/library/structures/amorph.h index d2104c70..6d817e8a 100644 --- a/nucleus/library/structures/amorph.h +++ b/nucleus/library/structures/amorph.h @@ -76,9 +76,12 @@ public: index "new_maximum" and upwards are thrown away. existing fields are kept. */ - void reset(int new_maximum = 0); + void resize(int new_maximum = 0); //!< like adjust but doesn't keep existing contents. + void reset() { this->resize(0); } + //!< cleans out all of the contents. + basis::outcome put(int field, const contents *data); //!< Enters an object into the field at index "field" in the amorph. /*!< If "data" is NIL, then the field is cleared. The amorph considers the @@ -180,7 +183,7 @@ private: // not to be used: amorphs should not be copied because it is intended that // they support storing heavyweight objects that either have no copy // constructors or have high-cost copy constructors. - amorph(const amorph &to_copy) {} //!< not to be used. + amorph(const amorph &to_copy) {_fields_used = 0;} //!< not to be used. amorph &operator = (const amorph &to_copy) { return *this; } //!< not to be used. }; @@ -280,7 +283,7 @@ void amorph::check_fields(const char *where) const } template -void amorph::reset(int new_maximum) +void amorph::resize(int new_maximum) { FUNCDEF("reset"); CHECK_FIELDS; @@ -370,7 +373,7 @@ basis::outcome amorph::put(int field, const contents *data) CHECK_FIELDS; bounds_return(field, 0, elements() - 1, basis::common::OUT_OF_RANGE); contents *to_whack = acquire(field); - WHACK(to_whack); + delete to_whack; if (data) { basis::array::access()[field] = (contents *)data; _fields_used++;