Skip to content

Commit 1ba558e

Browse files
committed
Format code
1 parent a17bd20 commit 1ba558e

27 files changed

+28
-59
lines changed

lib/lists/circular_doubly_linked_list.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import '../heaps/base.dart';
2-
31
import './doubly_linked_list.dart' show Node;
2+
import '../heaps/base.dart';
43

54
/// This circular linked list is based off of [DoublyLinkedList]
65
class CircularDoublyLinkedList<T> {

lib/lists/circular_singly_linked_list.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import '../heaps/base.dart';
2-
31
import './singly_linked_list.dart' show Node;
2+
import '../heaps/base.dart';
43

54
/// This circular linked list is based off of [SinglyLinkedList]
65
class CircularSinglyLinkedList<T> {

lib/trees/adt/binary_tree_adt.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ abstract class BinaryNodeADT<N extends BinaryNodeADT<N, V>,
88

99
/// Left child node.
1010
N? get left => children![0];
11+
1112
set left(N? node) => children![0] = node;
1213

1314
/// Right child node.
1415
N? get right => children![1];
16+
1517
set right(N? node) => children![1] = node;
1618

1719
@override
@@ -29,6 +31,7 @@ abstract class BinaryTreeADT<N extends BinaryNodeADT<N, V>,
2931

3032
@override
3133
bool contains(V value) => isEmpty ? false : _compareAndCheck(root!, value);
34+
3235
bool _compareAndCheck(N node, V value) {
3336
if (node.value == value) return true;
3437
return (node.value!.compareTo(value) >= 0

lib/trees/avl_tree.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
8585
else {
8686
var rGrandChild = lChild.right;
8787
switch (rGrandChild!.balanceFactor) {
88-
8988
// Addition is done in right subtree of [rGrandChild].
9089
case -1:
9190
node.balanceFactor = 0;
@@ -126,7 +125,6 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
126125
else {
127126
var lGrandChild = rChild.left;
128127
switch (lGrandChild!.balanceFactor) {
129-
130128
// Addition is done in right subtree of [lGrandChild].
131129
case -1:
132130
node.balanceFactor = 1;
@@ -194,7 +192,6 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
194192
/// Updates [balanceFactor] when addition is done in left subtree of [node].
195193
AvlNode<V> _aUpdateLeftBalanceFactor(AvlNode<V> node) {
196194
switch (node.balanceFactor) {
197-
198195
// node was balanced.
199196
case 0:
200197
// node is left heavy now.
@@ -220,7 +217,6 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
220217
/// Updates [balanceFactor] when addition is done in right subtree of [node].
221218
AvlNode<V> _aUpdateRightBalanceFactor(AvlNode<V> node) {
222219
switch (node.balanceFactor) {
223-
224220
// node was balanced.
225221
case 0:
226222
// node is right heavy now.
@@ -250,7 +246,6 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
250246
var lChild = node.left;
251247

252248
switch (lChild!.balanceFactor) {
253-
254249
// [lChild] was balanced, single right rotation about [node] is performed
255250
// to balance the [node].
256251
case 0:
@@ -302,12 +297,10 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
302297
// ......█ h+1 / \
303298
//
304299
case -1:
305-
306300
// Right subtree of [rChild].
307301
var rGrandChild = lChild.right;
308302

309303
switch (rGrandChild!.balanceFactor) {
310-
311304
// [rGrandChild] was balanced.
312305
case 0:
313306
// N N N
@@ -370,7 +363,6 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
370363
var rChild = node.right;
371364

372365
switch (rChild!.balanceFactor) {
373-
374366
// [rChild] was balanced, single left rotation about [node] is performed
375367
// to balance the [node].
376368
case 0:
@@ -423,12 +415,10 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
423415
// h+1 █...... / \
424416
//
425417
case 1:
426-
427418
// Left subtree of [rChild].
428419
var lGrandChild = rChild.left;
429420

430421
switch (lGrandChild!.balanceFactor) {
431-
432422
// [lGrandChild] was balanced.
433423
case 0:
434424
// N N N
@@ -572,7 +562,6 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
572562
/// subtree.
573563
AvlNode<V> _dUpdateLeftBalanceFactor(AvlNode<V> node) {
574564
switch (node.balanceFactor) {
575-
576565
// [node] was balanced before deletion, is right heavy now.
577566
case 0:
578567
// N N
@@ -619,7 +608,6 @@ class AvlTree<V extends Comparable> extends BinaryTreeADT<AvlNode<V>, V> {
619608
/// right subtree.
620609
AvlNode<V> _dUpdateRightBalanceFactor(AvlNode<V> node) {
621610
switch (node.balanceFactor) {
622-
623611
// node was balanced before deletion, is left heavy now.
624612
case 0:
625613
// N N

lib/trees/red_black_tree.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ class RedBlackTree<V extends Comparable>
303303
if (sibling?.color == Color.black &&
304304
(nearNephew!.color == Color.red || farNephew!.color == Color.red)) {
305305
switch (farNephew!.color) {
306-
307306
// Far nephew is black, perform rotation on [sibling]
308307
// and convert it to other case.
309308
case Color.black:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Implementation of algorithms with Dart.
55
# author: Mafinar K <mafinar@gmail.com>
66

77
environment:
8-
sdk: '>=2.13.0-0 <3.0.0'
8+
sdk: '>=2.19.0-0 <3.0.0'
99

1010
#dependencies:
1111
# path: ^1.4.1

test/graph/bellman_ford_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import 'package:test/test.dart';
2-
31
import 'package:algorithms/graph/bellman_ford.dart';
42
import 'package:algorithms/graph/simple_graph.dart';
53
import 'package:algorithms/graph/vertex.dart';
4+
import 'package:test/test.dart';
65

76
void main() {
87
late SimpleGraph graph;

test/graph/bfs_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import 'package:test/test.dart';
2-
31
import 'package:algorithms/graph/bfs.dart';
42
import 'package:algorithms/graph/simple_graph.dart';
53
import 'package:algorithms/graph/vertex.dart';
4+
import 'package:test/test.dart';
65

76
void main() {
87
late SimpleGraph graph;

test/graph/dfs_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import 'package:test/test.dart';
2-
31
import 'package:algorithms/graph/dfs.dart';
42
import 'package:algorithms/graph/simple_graph.dart';
53
import 'package:algorithms/graph/vertex.dart';
4+
import 'package:test/test.dart';
65

76
void main() {
87
late SimpleGraph graph;

test/graph/dijkstra_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import 'package:test/test.dart';
2-
31
import 'package:algorithms/graph/dijkstra.dart';
42
import 'package:algorithms/graph/simple_graph.dart';
53
import 'package:algorithms/graph/vertex.dart';
4+
import 'package:test/test.dart';
65

76
void main() {
87
late SimpleGraph graph;

0 commit comments

Comments
 (0)