MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / SearchTree

Method SearchTree

neo/tools/comafx/CPathTreeCtrl.cpp:189–229  ·  view source on GitHub ↗

================ CPathTreeCtrl::SearchTree Search the three using the search string. Adds the matched tree items to the result tree. Returns the number of items added to the result tree. ================ */

Source from the content-addressed store, hash-verified

187================
188*/
189int CPathTreeCtrl::SearchTree( treeItemCompare_t compare, void *data, CPathTreeCtrl &result ) {
190 idPathTreeStack stack, searchStack;
191 HTREEITEM item, child;
192 idStr name;
193 int id, numItems;
194
195 numItems = 0;
196 result.DeleteAllItems();
197 stack.PushRoot( NULL );
198
199 item = GetRootItem();
200 searchStack.PushRoot( item );
201 id = 0;
202
203 while( searchStack.Num() > 0 ) {
204
205 for ( child = GetChildItem( item ); child; child = GetChildItem( child ) ) {
206 searchStack.Push( item, GetItemText( item ) );
207 item = child;
208 }
209
210 name = searchStack.TopName();
211 name += GetItemText( item );
212 id = GetItemData( item );
213
214 if ( compare( data, item, name ) ) {
215 result.AddPathToTree( name, id, stack );
216 numItems++;
217 }
218
219 for ( item = GetNextSiblingItem( item ); item == NULL; ) {
220 item = GetNextSiblingItem( searchStack.TopItem() );
221 searchStack.Pop();
222 if ( searchStack.Num() <= 0 ) {
223 return numItems;
224 }
225 }
226 }
227
228 return numItems;
229}
230
231BEGIN_MESSAGE_MAP(CPathTreeCtrl,CTreeCtrl)
232 //{{AFX_MSG_MAP(CPathTreeCtrl)

Callers 2

OnInitDialogMethod · 0.80
OnBnClickedFindMethod · 0.80

Calls 8

DeleteAllItemsMethod · 0.80
PushRootMethod · 0.80
TopNameMethod · 0.80
AddPathToTreeMethod · 0.80
TopItemMethod · 0.80
PopMethod · 0.80
NumMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected