Commit 0a7c2d15 by huchi

replace STL functions to C functions

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