Попробовал пример для RadixTree
Код:
CompilerIf #PB_Compiler_IsMainFile ; CompilerIf #False #Window = 0 Enumeration #Str #Editor EndEnumeration Define Tree.RadixTree Define NewList Dictionary.s() Define NewList *Found() Define i ;- ╔═ GUI ═╗ If OpenWindow(#Window, 0, 0, 320, 350, "RadixTree (начини ввод с 'п')", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) StringGadget(#Str, 8, 10, 306, 30, "") EditorGadget(#Editor, 8, 45, 306, 300) AddElement(Dictionary()) Dictionary() = "порыв" AddElement(Dictionary()) Dictionary() = "привет" AddElement(Dictionary()) Dictionary() = "пропаганда" AddElement(Dictionary()) Dictionary() = "пропасть" AddElement(Dictionary()) Dictionary() = "против" ; добавляю элементы ForEach Dictionary() RadixInsert(Tree, Dictionary(), PeekI(@Dictionary())) Next ;- Loop Repeat Select WaitWindowEvent() Case #PB_Event_Gadget Select EventGadget() Case #Str If EventType() = #PB_EventType_Change Prefix$ = GetGadgetText(#Str) ClearList(*Found()) ClearGadgetItems(#Editor) RadixEnumeratePrefix(Tree, Prefix$, *Found()) ; найти по префиксу, по началу введённого текста i = 0 ForEach *Found() i + 1 ; Debug PeekS(*Found()) AddGadgetItem(#Editor , i , PeekS(*Found())) Next EndIf EndSelect Case #PB_Event_CloseWindow CloseWindow(#Window) End EndSelect ForEver EndIf CompilerEndIf
Отредактировано AZJIO (13.02.2024 12:15:03)