46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
// import "package:fast_network_navigation/structs/landmark.dart";
|
|
|
|
// class Linked<Landmark> {
|
|
// Landmark? head;
|
|
|
|
// Linked();
|
|
|
|
// // class methods
|
|
// bool get isEmpty => head == null;
|
|
|
|
// // Add a new node to the end of the list
|
|
// void add(Landmark value) {
|
|
// if (isEmpty) {
|
|
// // If the list is empty, set the new node as the head
|
|
// head = value;
|
|
// } else {
|
|
// Landmark? current = head;
|
|
// while (current!.next != null) {
|
|
// // Traverse the list to find the last node
|
|
// current = current.next;
|
|
// }
|
|
// current.next = value; // Set the new node as the next node of the last node
|
|
// }
|
|
// }
|
|
|
|
// // Remove the first node with the given value
|
|
// void remove(Landmark value) {
|
|
// if (isEmpty) return;
|
|
|
|
// // If the value is in the head node, update the head to the next node
|
|
// if (head! == value) {
|
|
// head = head.next;
|
|
// return;
|
|
// }
|
|
|
|
// var current = head;
|
|
// while (current!.next != null) {
|
|
// if (current.next! == value) {
|
|
// // If the value is found in the next node, skip the next node
|
|
// current.next = current.next.next;
|
|
// return;
|
|
// }
|
|
// current = current.next;
|
|
// }
|
|
// }
|
|
// } |