summaryrefslogtreecommitdiff
path: root/common/array.cpp
diff options
context:
space:
mode:
authorleo2006-01-03 01:34:03 +0000
committerleo2006-01-03 01:34:03 +0000
commitb463aef5bdc800972f61d9d6ee8087533f011dff (patch)
treee49ca45112cb05a69e83b22dd8f629cb8fadb055 /common/array.cpp
parent43be715ad595e58f3381439c88defb209aa06f89 (diff)
Fixed subpieces in the pieces bar.
git-svn-id: http://svn.leocad.org/trunk@451 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/array.cpp')
-rwxr-xr-xcommon/array.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/array.cpp b/common/array.cpp
index 76c9a30..8d1b663 100755
--- a/common/array.cpp
+++ b/common/array.cpp
@@ -121,6 +121,36 @@ int PtrArray<T>::FindIndex(T* Obj) const
}
template <class T>
+void PtrArray<T>::Sort(LC_PTRARRAY_COMPARE_FUNC SortFunc, void* SortData)
+{
+ int Count = GetSize();
+
+ if (Count <= 1)
+ return;
+
+ int i = 1;
+ bool Flipped;
+
+ do
+ {
+ Flipped = false;
+
+ for (int j = Count - 1; j >= i; --j)
+ {
+ T* a = m_pData[j];
+ T* b = m_pData[j-1];
+
+ if (SortFunc(b, a, SortData) > 0)
+ {
+ m_pData[j - 1] = a;
+ m_pData[j] = b;
+ Flipped = true;
+ }
+ }
+ } while ((++i < Count) && Flipped);
+}
+
+template <class T>
PtrArray<T>& PtrArray<T>::operator=(const PtrArray<T>& Array)
{
m_nLength = Array.m_nLength;