+WX_DECLARE_OBJARRAY(wxHtmlHelpMergedIndexItem, wxHtmlHelpMergedIndex);
+#include "wx/arrimpl.cpp"
+WX_DEFINE_OBJARRAY(wxHtmlHelpMergedIndex)
+
+void wxHtmlHelpFrame::UpdateMergedIndex()
+{
+ delete m_mergedIndex;
+ m_mergedIndex = new wxHtmlHelpMergedIndex;
+ wxHtmlHelpMergedIndex& merged = *m_mergedIndex;
+
+ const wxHtmlHelpDataItems& items = m_Data->GetIndexArray();
+ size_t len = items.size();
+
+ wxHtmlHelpMergedIndexItem *history[128] = {NULL};
+
+ for (size_t i = 0; i < len; i++)
+ {
+ const wxHtmlHelpDataItem& item = items[i];
+ wxASSERT_MSG( item.level < 128, _T("nested index entries too deep") );
+
+ if (history[item.level] &&
+ history[item.level]->items[0]->name == item.name)
+ {
+ // same index entry as previous one, update list of items
+ history[item.level]->items.Add(&item);
+ }
+ else
+ {
+ // new index entry
+ wxHtmlHelpMergedIndexItem *mi = new wxHtmlHelpMergedIndexItem();
+ mi->name = item.GetIndentedName();
+ mi->items.Add(&item);
+ mi->parent = (item.level == 0) ? NULL : history[item.level - 1];
+ history[item.level] = mi;
+ merged.Add(mi);
+ }
+ }
+}