From 91995f6ab25ddc86e72c00f794333cff81b9130b Mon Sep 17 00:00:00 2001 From: hlccd <56643462+hlccd@users.noreply.github.com> Date: Wed, 20 Oct 2021 22:04:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=8A=A8=E6=80=81=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E5=AE=9E=E7=8E=B0=E4=BA=86vector=EF=BC=8C=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E5=B9=B6=E5=8F=91=E6=8E=A7=E5=88=B6=E9=94=81=E4=BF=9D?= =?UTF-8?q?=E8=AF=81=E4=BA=86=E5=9C=A8=E9=AB=98=E5=B9=B6=E5=8F=91=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E4=B8=AD=E7=9A=84=E7=BA=BF=E7=A8=8B=E5=AE=89=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- goSTL/data_structure/vector/vector.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/goSTL/data_structure/vector/vector.go b/goSTL/data_structure/vector/vector.go index dba3098..fcfda91 100644 --- a/goSTL/data_structure/vector/vector.go +++ b/goSTL/data_structure/vector/vector.go @@ -246,7 +246,7 @@ func (v *vector) PopBack() { } v.mutex.Lock() v.len-- - if v.cap-v.len >= 2^16 { + if v.cap-v.len >= 65536 { //容量和实际使用差值超过2^16时,容量直接减去2^16 v.cap -= 2 ^ 16 tmp := make([]interface{}, v.cap, v.cap) @@ -283,7 +283,7 @@ func (v *vector) Insert(idx uint64, e interface{}) { var tmp []interface{} if v.len >= v.cap { //冗余不足,进行扩容 - if v.cap <= 2^16 { + if v.cap <= 65536 { //容量翻倍 if v.cap == 0 { v.cap = 1 @@ -332,7 +332,7 @@ func (v *vector) Erase(idx uint64) { v.data[p] = v.data[p+1] } v.len-- - if v.cap-v.len >= 2^16 { + if v.cap-v.len >= 65536 { //容量和实际使用差值超过2^16时,容量直接减去2^16 v.cap -= 2 ^ 16 tmp := make([]interface{}, v.cap, v.cap)