Created
August 2, 2018 06:12
-
-
Save laevandus/f675fe39ce231818cadd4627b66e5619 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Populating parking lot.") | |
var parkingLot = LinkedList<String>() | |
parkingLot.prepend(LinkedList.Node("Car")) | |
let truck = parkingLot.prepend(LinkedList.Node("Truck")) | |
parkingLot.insert(LinkedList.Node("Chopper"), after: truck) | |
parkingLot.forEach(body: { print($0.value) }) | |
print("Empty: \(parkingLot.isEmpty)") | |
/* | |
Populating parking lot. | |
Truck | |
Chopper | |
Car | |
Empty: false | |
*/ | |
print("Rearranging parking lot.") | |
parkingLot.remove(after: truck) | |
parkingLot.forEach(body: { print($0.value) }) | |
/* | |
Rearranging parking lot. | |
Truck | |
Car | |
*/ | |
print("Populating numbers.") | |
var numbers = LinkedList<Int>() | |
let first = numbers.prepend(LinkedList.Node(1)) | |
numbers.insert(LinkedList.Node(2), after: first) | |
numbers.forEach(body: { print($0.value) }) | |
/* | |
Populating numbers. | |
1 | |
2 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment