]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/string.h
no message
[wxWidgets.git] / include / wx / string.h
index d21eb47a473242cafd7a8316a7fff38139dbb839..576d9661663cd54ed4e95b8d2a7015b671a398e7 100644 (file)
@@ -869,8 +869,9 @@ public:
                                  const wxString& second);
 
   // constructors and destructor
-    // default ctor
-  wxArrayString();
+    // default ctor: if autoSort is TRUE, the array is always sorted (in
+    // alphabetical order)
+  wxArrayString(bool autoSort = FALSE);
     // copy ctor
   wxArrayString(const wxArrayString& array);
     // assignment operator
@@ -911,8 +912,9 @@ public:
     // sensitive (default). Returns index of the first item matched or
     // wxNOT_FOUND
   int  Index (const wxChar *sz, bool bCase = TRUE, bool bFromEnd = FALSE) const;
-    // add new element at the end
-  void Add(const wxString& str);
+    // add new element at the end (if the array is not sorted), return its
+    // index
+  size_t Add(const wxString& str);
     // add new element at given position
   void Insert(const wxString& str, size_t uiIndex);
     // remove first item matching this value
@@ -927,16 +929,30 @@ public:
     // sort array elements using specified comparaison function
   void Sort(CompareFunction compareFunction);
 
+protected:
+  void Copy(const wxArrayString& src);  // copies the contents of another array
+
 private:
-  void    Grow();     // makes array bigger if needed
-  void    Free();     // free the string stored
+  void Grow();                          // makes array bigger if needed
+  void Free();                          // free all the strings stored
 
-  void    DoSort();   // common part of all Sort() variants
+  void DoSort();                        // common part of all Sort() variants
 
   size_t  m_nSize,    // current size of the array
           m_nCount;   // current number of elements
 
-  wxChar  **m_pItems;   // pointer to data
+  wxChar  **m_pItems; // pointer to data
+
+  bool    m_autoSort; // if TRUE, keep the array always sorted
+};
+
+class WXDLLEXPORT wxSortedArrayString : public wxArrayString
+{
+public:
+  wxSortedArrayString() : wxArrayString(TRUE)
+    { }
+  wxSortedArrayString(const wxArrayString& array) : wxArrayString(TRUE)
+    { Copy(array); }
 };
 
 // ---------------------------------------------------------------------------