Ticket #9268: 0002-BStringList-implemented-Sort-with-custom-sort-functi.patch

File 0002-BStringList-implemented-Sort-with-custom-sort-functi.patch, 1.3 KB (added by dknoto, 7 years ago)
  • headers/os/support/StringList.h

    From 1833c6f88b69331f896af9280fd28063e81254ba Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Dariusz=20Knoci=C5=84ski?= <dknoto@gmail.com>
    Date: Thu, 6 Dec 2012 23:13:27 +0100
    Subject: [PATCH 2/2] BStringList: implemented Sort() with custom sort
     function.
    
    ---
     headers/os/support/StringList.h |    3 ++-
     src/kits/support/StringList.cpp |    8 ++++++++
     2 files changed, 10 insertions(+), 1 deletion(-)
    
    diff --git a/headers/os/support/StringList.h b/headers/os/support/StringList.h
    index e58956b..13b06fc 100644
    a b public:  
    3636
    3737    // Reorder items
    3838            void                Sort(bool ignoreCase = false);
    39                                     // TODO: Sort() with custom sort function.
     39            void                Sort(int (*compareFunc)(const void*, const void*))
     40
    4041            bool                Swap(int32 indexA, int32 indexB);
    4142            bool                Move(int32 fromIndex, int32 toIndex);
    4243
  • src/kits/support/StringList.cpp

    diff --git a/src/kits/support/StringList.cpp b/src/kits/support/StringList.cpp
    index 7b453d8..61904c4 100644
    a b BStringList::Sort(bool ignoreCase)  
    202202}
    203203
    204204
     205void
     206BStringList::Sort(int (*compareFunc)(const void*, const void*))
     207{
     208    if (compareFunc != NULL)
     209        fStrings.SortItems(compareFunc);
     210}
     211
     212
    205213bool
    206214BStringList::Swap(int32 indexA, int32 indexB)
    207215{