From 03ef0b51103c735077c784c7df81ae2bcc1599ab Mon Sep 17 00:00:00 2001 From: LiFan <2308045698@qq.com> Date: 星期四, 13 二月 2025 18:33:56 +0800 Subject: [PATCH] update --- jrj/xframe/adt/xarray.hpp | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/jrj/xframe/adt/xarray.hpp b/jrj/xframe/adt/xarray.hpp index 63346d6..5db0865 100644 --- a/jrj/xframe/adt/xarray.hpp +++ b/jrj/xframe/adt/xarray.hpp @@ -8,10 +8,10 @@ class xarray : public xobject { public: - xarray(length_(0), capacity_(0),itemms(nullptr){ - } + xarray():length_(0), capacity_(0), items(nullptr) {} + public: - xarray*push_back(T t) + xarray* push_back(T t) { sure_space(); @@ -20,11 +20,19 @@ return this; } + xarray* pop_back() { if (length() > 0) erase(length() - 1); return this; + } + + void clear() + { + for (int i = 0; i <= length(); i++) + items[i].~T(); + length_ = 0; } xarray* erase(int index) @@ -115,7 +123,7 @@ { temp[i] = items[i]; } - delete items; + delete[] items; items = temp; } } @@ -125,4 +133,6 @@ T* items; int length_; int capacity_; -}; \ No newline at end of file +}; + + -- Gitblit v1.9.3