Знающий
Регистрация: 17.07.2009
Сообщений: 201
Написано 53 полезных сообщений (для 75 пользователей)
|
Ответ: LinkedList
Обновлённый "двунаправленный список" LinkedList.rar
Тест код в оффтоп:

Include "LinkedList.bb"
Graphics 800,600,32,2 SetBuffer BackBuffer() fntArial = LoadFont("Arial",20) SetFont fntArial
Type Point Field x#, y# End Type p.Point = Object.Point( Handle( New Point)) ; Object <- Handle p\x = 200 p\y = 160
all_node = False positive_negative = False free_Node_ID = 0 free_List_ID = 0 num = 0 n.Node = Null t1.List = NewList(" t1 ") Push( t1, Null, "Push", -1, Handle( p)) ; Handle( p) Push( t1, Null, "push 2", 0) num = num + 3 Push( t1, Null, "pusH " + num, 0.2) DelByIndex(t1, 2) UnShift( t1, Null, "unShift", 33) ;UnShift( t1, Null, "unShift 2", 7) ;UnShift( t1, Null, "unShift 3", 12) InsertList( t1, NewNode( "Insert", 67), 2) n = NewNode( "newNode 3") n\list = NewList(" g ") ; : If n\list <> Null Then DebugLog "n\list = Try" Else DebugLog "n\list = None" InsertList( t1, n, 3) ;n = nodeByText( t1, "newNode 3") : If n\list <> Null Then DebugLog "n\list = Try" Else DebugLog "n\list = None"
t.List = NewList("S") Push( t, Null, "S_push", 0.75) Push( t, Null, "S_push 2", -11) Push( t, Null, "S_push 2", 0, Handle( t1)) ; Handle( t1) n1.Node = NewNode( "", -5) n1\list = t InsertList( t1, n1, t1\totalNode) tt.List = NewList("S") Push( tt, Null, "S_push", 0.75) Push( tt, Null, "S_push 2", -11) Push( tt, Null, "S_push 2", 0, Handle( t)) ; Handle( t1) Push( t1, Null, "", 0, Handle( tt)) ;by_Index.Node = byIndex(t1, t1\totalNode) ;If nodeBy_Index <> Null Then DebugLog "Index " + t1\totalNode + " = Try" Else DebugLog "Index 1 = None" ;If nodeById(t1, 2) <> Null Then DebugLog "ID 2 = Try" Else DebugLog "ID 2 = None" ;If nodeByText(t1, "push") <> Null Then DebugLog "Text = Try" Else DebugLog "Text = None" t2.List = NewList(" t2 ") t3.List = NewList(" t3 ") t3\name = " t3 " free_List_ID = FreeListID() free_Node_ID = FreeNodeID() ;SortByID(t1, 1) While Not KeyHit(1) Cls ;If KeyHit(11) Then Push( t1, Shift(t1)) ; key "0" If KeyHit(2) Then Push( t1, Shift(t1)) ; key "1" If KeyHit(3) Then UnShift( t1, Pop(t1)) ; key "2" If KeyHit(4) Then Pop(t1) ; key "3" If KeyHit(5) Then Shift(t1) ; key "4" If KeyHit(6) Then SortList( t1, LOWERTEXT, positive_negative) ; key "5" If KeyHit(7) Then SortList( t1, NUMERIC, positive_negative) ; key "6" If KeyHit(8) Then SortList( t1, LISTNULL, positive_negative) ; key "7" If KeyHit(9) Then SortList( t1, LOWERTEXT Or NUMERIC, positive_negative) ; key "8" If KeyHit(28) Then positive_negative = Not positive_negative ; key "Enter" If KeyHit(30) Then all_node = Not all_node ; key "A" If KeyHit(17) Then SwapNode( nodebyIndex(t1, 1), nodebyIndex(t1, 2)) ; key "W" If KeyHit(33) Then free_Node_ID = FreeNodeID() ; key "F" If KeyHit(23) Then ListInverse(t1) ; key "I" If KeyHit(19) Then ListReverse(t1, t1) ; key "R" If KeyHit(31) Then ListSlice( t1, t3, 2, 3) ; key "S" If KeyHit(16) Then SortByID(t1, positive_negative) ; key "Q" If KeyHit(18) Then ListErase(t2) ; key "E" If KeyHit(25) Then num = num + 1 : Push( t1, Null, "pusH " + num, num) ; key "P" If KeyHit(32) Then DelByIndex(t1, 1) ; key "D" If KeyHit(46) Then CopyList(t1, t2) ; key "C" If KeyHit(37) Then t2 = CloneList(t1) ; key "K" If KeyHit(45) Then DeleteList(t3) ; key "X" If all_node = False Then AllListNode( 30, 70) ;AllNode( 30, 20) ;AllList( 30, 400) Else ListText(t1, 30, 60) ListText(t2, 30, 240) ListText(t3, 30, 440) EndIf If positive_negative Then Text 10, 2, "positive_negative = True, positive [ 1 ... ] " Else Text 10, 2, "positive_negative = False, negative [ ... 1 ]" EndIf Text 10, 22, "free Node ID = " + free_Node_ID + ", max Node ID = " + NodeID + ", pool Node ID = " + poolNodeID Text 10, 42, "free List ID = " + free_List_ID + ", max List ID = " + ListID + ", pool List ID = " + poolListID ;If n <> Null Then Text 220, 22, "[ n ] 'ID' : " + n\id + ", 'Text' : " + n\txt + " " n = nodeByText( t1, "Push") If n <> Null Then pp.Point = Object.Point( n\Hndl) If pp <> Null Then Text 470, 2, "Oblect_Handle ... Point " + pp\x + " " + pp\y EndIf Flip Wend ;: FlushKeys : WaitKey End
__________________
Мой проект здесь
Последний раз редактировалось Randomize, 09.04.2025 в 13:51.
|