Commit 0a7c2d15 by huchi

replace STL functions to C functions

parent 25fd50be
......@@ -254,6 +254,13 @@ void TensorListBase<T>::Clear()
}
/*
compare function for two elements
*/
int Compare(const void* a, const void* b) {
return (*(int*)(a)-*(int*)(b));
}
/*
sort the list
>> itemSize - size of an item
>> comp - the comparison function used in sorting
......@@ -261,7 +268,7 @@ sort the list
template <typename T>
void TensorListBase<T>::Sort(int itemSize)
{
std::sort(items, items + count);
qsort((void*)items, count, itemSize, Compare);
}
/* reverse the list */
......@@ -270,9 +277,9 @@ inline void TensorListBase<T>::Reverse()
{
int half = count / 2;
for (int i = 0; i < half; i++) {
T tmp(std::move(items[i]));
items[i] = std::move(items[count - i - 1]);
items[count - i - 1] = std::move(tmp);
T tmp(items[i]);
items[i] = items[count - i - 1];
items[count - i - 1] = tmp;
}
}
......
......@@ -119,8 +119,6 @@ public:
void Set(int i, T item) { SetItem(i, item); };
};
struct XTensor;
typedef TensorListBase<int> IntList;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论