mirror of
https://review.haiku-os.org/haiku
synced 2025-02-22 21:48:35 +01:00
Added Sort() functionality.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13494 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7560d40290
commit
4852c3cd50
@ -24,6 +24,8 @@
|
||||
// Description: A helper class for TRoster. A list of RosterAppInfos.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "AppInfoList.h"
|
||||
@ -181,6 +183,21 @@ AppInfoList::It()
|
||||
return Iterator(this, 0);
|
||||
}
|
||||
|
||||
// Sort
|
||||
/*! \brief Sorts the infos in ascending order according to the given compare
|
||||
function.
|
||||
\param cmpFunc The compare function to be used.
|
||||
*/
|
||||
void
|
||||
AppInfoList::Sort(int (*cmpFunc)(const RosterAppInfo *, const RosterAppInfo *))
|
||||
{
|
||||
int32 count = CountInfos();
|
||||
if (count > 1) {
|
||||
RosterAppInfo **infos = (RosterAppInfo **)fInfos.Items();
|
||||
sort(infos, infos + count, cmpFunc);
|
||||
}
|
||||
}
|
||||
|
||||
// RemoveInfo
|
||||
/*! \brief Removes a RosterAppInfo at a given index.
|
||||
\param index The index of the info to be removed
|
||||
|
@ -57,6 +57,8 @@ public:
|
||||
|
||||
Iterator It();
|
||||
|
||||
void Sort(int (*cmpFunc)(const RosterAppInfo *, const RosterAppInfo *));
|
||||
|
||||
private:
|
||||
RosterAppInfo *RemoveInfo(int32 index);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user