tlist_insertbeforelink.bmx 693 B

123456789101112131415161718192021222324252627282930313233
  1. SuperStrict
  2. Framework Brl.LinkedList
  3. Import Brl.StandardIO
  4. ' create a list to hold some objects
  5. Local list:TList = New TList
  6. ' add some string objects to the end of the list
  7. list.AddLast("one")
  8. list.AddLast("two")
  9. list.AddLast("three")
  10. ' find the link we want to insert something before or after, here for "two"
  11. Local link:TLink = list.FindLink("two")
  12. 'insert a new element before the link
  13. list.InsertBeforeLink("before two", link)
  14. 'insert a new element after the link
  15. list.InsertAfterLink("after two", link)
  16. ' enumerate all the strings in the list
  17. For Local a:String = EachIn list
  18. Print a
  19. Next
  20. ' outputs:
  21. ' one
  22. ' before two
  23. ' two
  24. ' after two
  25. ' three