tobjectlist_swap.bmx 593 B

123456789101112131415161718192021222324252627282930313233
  1. SuperStrict
  2. Framework Brl.ObjectList
  3. Import Brl.StandardIO
  4. ' create an object list to hold some objects
  5. Local list:TObjectList = New TObjectList
  6. ' add some string objects to the end of the list
  7. list.AddLast("one")
  8. list.AddLast("two")
  9. list.AddLast("three")
  10. ' create a second object list
  11. Local list2:TObjectList = New TObjectList
  12. list2.AddLast("four")
  13. list2.AddLast("five")
  14. list2.AddLast("six")
  15. ' swap the lists
  16. list.Swap(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