fixed bug in array.insert(index,array)
This commit is contained in:
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.
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;
|
||||
|
||||
16
src/main.cpp
16
src/main.cpp
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user