fixed bug in array.insert(index,array)

This commit is contained in:
madrocketsci committed 2026-04-27 19:25:59 -04:00
1 parent 9409daefb4
commit a704893c1d
26 files changed
+13 -11

No files matched your search

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)
{
oldlen = this->length;
res = this->resize_insert(this->length + other.length);
res = this->resize_insert(oldlen + other.length);
if(res==amsarray_success)
{
//for now, do things single threaded.
//to do things multithreaded, I'd need another buffer
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++)
{
@@ -300,6 +300,7 @@ template<typename T> int amsarray_quicksort_threaded(
rangeptr = 0;
ranges.append(ams::pair<amsarray_size_t,amsarray_size_t>(0,array->length));
while(rangeptr<ranges.length)
{
//spawn up to the maximum number of threads
@@ -340,6 +341,7 @@ template<typename T> int amsarray_quicksort_threaded(
}
//rangeptr++;
}
}
return ret;
+8 -8
View File
@@ -8,14 +8,14 @@ int main(int argc, char* argv[])
int ret = 0;
printf("ams c++ math and utility library tests.\n");
ams::amsmathutil25::test_amsarray1();
ams::amsmathutil25::test_amsarray2();
ams::amsmathutil25::test_amsarray_select();
ams::amsmathutil25::test_amsarray_sort1();
test_amsarray_insertdelete1();
test_amsarray_insertdelete2();
test_amsarray_minimal();
test_amsarray_arrayinsert();
//ams::amsmathutil25::test_amsarray1();
//ams::amsmathutil25::test_amsarray2();
//ams::amsmathutil25::test_amsarray_select();
//ams::amsmathutil25::test_amsarray_sort1();
//test_amsarray_insertdelete1();
//test_amsarray_insertdelete2();
//test_amsarray_minimal();
//test_amsarray_arrayinsert();
return ret;