swaplists.bmx 596 B

123456789101112131415161718192021222324252627282930313233
  1. SuperStrict
  2. Framework Brl.LinkedList
  3. Import Brl.StandardIO
  4. ' create a list to hold some objects
  5. Local list:TList = CreateList()
  6. ' add some string objects to the end of the list
  7. ListAddLast(list, "one")
  8. ListAddLast(list, "two")
  9. ListAddLast(list, "three")
  10. ' create a second list
  11. Local list2:TList = CreateList()
  12. ListAddLast(list2, "four")
  13. ListAddLast(list2, "five")
  14. ListAddLast(list2, "six")
  15. ' swap the lists
  16. SwapLists(list, list2)
  17. ' enumerate all the strings in the first list
  18. For Local a:String = EachIn list
  19. Print a
  20. Next
  21. ' outputs:
  22. ' four
  23. ' five
  24. ' six