diff --git a/data_structures/HashMap/Hashing.dart b/data_structures/HashMap/Hashing.dart index 3aaeb852..ecc23d27 100644 --- a/data_structures/HashMap/Hashing.dart +++ b/data_structures/HashMap/Hashing.dart @@ -70,7 +70,8 @@ class HashMap { List buckets; HashMap(int hsize) { - buckets = new List(hsize); + buckets = []..length = hsize; + for (int i = 0; i < hsize; i++) { buckets[i] = new LinkedList(); } diff --git a/data_structures/Queue/Circular_Queue.dart b/data_structures/Queue/Circular_Queue.dart index 6d870555..e3950c62 100644 --- a/data_structures/Queue/Circular_Queue.dart +++ b/data_structures/Queue/Circular_Queue.dart @@ -6,7 +6,7 @@ const int MAX_SIZE = 10; class CircularQueue { int start = -1, end = -1; - List queue = new List(MAX_SIZE); + List queue = []..length = MAX_SIZE; // insert elements into the queue void enque(T element) { diff --git a/data_structures/Queue/List_Queue.dart b/data_structures/Queue/List_Queue.dart index 6fb61bfb..b78d4cd7 100644 --- a/data_structures/Queue/List_Queue.dart +++ b/data_structures/Queue/List_Queue.dart @@ -5,7 +5,7 @@ const int MAX_SIZE = 10; class ListQueue { int count = 0; - List queue = new List(MAX_SIZE); + List queue = []..length = MAX_SIZE; //Checks if the queue has elements (not empty) bool hasElements() { diff --git a/data_structures/linked_list/cycle_in_linked_list.dart b/data_structures/linked_list/cycle_in_linked_list.dart index 5582046c..ca29efa1 100644 --- a/data_structures/linked_list/cycle_in_linked_list.dart +++ b/data_structures/linked_list/cycle_in_linked_list.dart @@ -79,7 +79,7 @@ Node findCyclicNode(Node headNode) { void main() { LinkedList linkedList = LinkedList(); - List allNodes = List(); + List allNodes = []; for (var i = 0; i <= 10; i++) { Node newNode = createNode(i); linkedList.insert(newNode); diff --git a/graphs/depth_first_search.dart b/graphs/depth_first_search.dart index c60ca4fc..ac85cffd 100644 --- a/graphs/depth_first_search.dart +++ b/graphs/depth_first_search.dart @@ -14,7 +14,7 @@ class Graph { /// each node will have a list as value which stores /// the nodes to which it is connected to for (int i = 0; i < this.nodes.length; i++) { - this.graph[nodes[i]] = List(); + this.graph[nodes[i]] = []; } } @@ -32,7 +32,7 @@ class Graph { void addNodes(int newNode) { this.nodes.add(newNode); - this.graph[newNode] = List(); + this.graph[newNode] = []; } void addEdges(int start, int end) { @@ -59,7 +59,7 @@ List depthFirstSearch(Graph graph, int numberOfNodes, int startNode) { List visitedNodes = new List.generate(numberOfNodes, (index) => false); - List answer = List(); + List answer = []; depthFirstSearchHelper(graph.graph, visitedNodes, startNode, answer); return answer; } diff --git a/other/N_bonacci.dart b/other/N_bonacci.dart index 217417a7..545db206 100644 --- a/other/N_bonacci.dart +++ b/other/N_bonacci.dart @@ -1,7 +1,7 @@ import 'package:test/test.dart'; List N_bonacci(int n, int m) { - List v = new List(m); + List v = []..length = m; var i; for (i = 0; i < m; i++) { v[i] = 0; diff --git a/sort/merge_sort.dart b/sort/merge_sort.dart index 9da909e3..f7bdfa3e 100644 --- a/sort/merge_sort.dart +++ b/sort/merge_sort.dart @@ -4,8 +4,7 @@ void merge(List list, int lIndex, int mIndex, int rIndex) { int lSize = mIndex - lIndex + 1; int rSize = rIndex - mIndex; - List lList = new List(lSize); - List rList = new List(rSize); + List lList = []..length = lSize, rList = []..length = rSize; for (int i = 0; i < lSize; i++) lList[i] = list[lIndex + i]; for (int j = 0; j < rSize; j++) rList[j] = list[mIndex + j + 1];