fixed bug in array.insert(index,array)

This commit is contained in:
2026-04-27 19:25:59 -04:00
parent 9409daefb4
commit a704893c1d
26 changed files with 13 additions and 11 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -493,16 +493,16 @@ template<typename T> int amsarray<T>::insert(amsarray_size_t ind, const amsarray
else if(ind<=this->length) else if(ind<=this->length)
{ {
oldlen = this->length; oldlen = this->length;
res = this->resize_insert(this->length + other.length); res = this->resize_insert(oldlen + other.length);
if(res==amsarray_success) if(res==amsarray_success)
{ {
//for now, do things single threaded. //for now, do things single threaded.
//to do things multithreaded, I'd need another buffer //to do things multithreaded, I'd need another buffer
if(this->data!=NULL && other.data!=NULL) if(this->data!=NULL && other.data!=NULL)
{ {
for(I=oldlen;I>=ind+other.length;I--) for(I=oldlen+other.length-1;I>=ind+other.length;I--)
{ {
this->data[I] = std::move(this->data[I-1]); this->data[I] = std::move(this->data[I-other.length]);
} }
for(I=ind;I<ind+other.length;I++) for(I=ind;I<ind+other.length;I++)
{ {
@@ -300,6 +300,7 @@ template<typename T> int amsarray_quicksort_threaded(
rangeptr = 0; rangeptr = 0;
ranges.append(ams::pair<amsarray_size_t,amsarray_size_t>(0,array->length)); ranges.append(ams::pair<amsarray_size_t,amsarray_size_t>(0,array->length));
while(rangeptr<ranges.length) while(rangeptr<ranges.length)
{ {
//spawn up to the maximum number of threads //spawn up to the maximum number of threads
@@ -340,6 +341,7 @@ template<typename T> int amsarray_quicksort_threaded(
} }
//rangeptr++; //rangeptr++;
} }
} }
return ret; return ret;
+8 -8
View File
@@ -8,14 +8,14 @@ int main(int argc, char* argv[])
int ret = 0; int ret = 0;
printf("ams c++ math and utility library tests.\n"); printf("ams c++ math and utility library tests.\n");
ams::amsmathutil25::test_amsarray1(); //ams::amsmathutil25::test_amsarray1();
ams::amsmathutil25::test_amsarray2(); //ams::amsmathutil25::test_amsarray2();
ams::amsmathutil25::test_amsarray_select(); //ams::amsmathutil25::test_amsarray_select();
ams::amsmathutil25::test_amsarray_sort1(); //ams::amsmathutil25::test_amsarray_sort1();
test_amsarray_insertdelete1(); //test_amsarray_insertdelete1();
test_amsarray_insertdelete2(); //test_amsarray_insertdelete2();
test_amsarray_minimal(); //test_amsarray_minimal();
test_amsarray_arrayinsert(); //test_amsarray_arrayinsert();
return ret; return ret;