Skip to content

Commit 15d2778

Browse files
committed
Remove needless parenthesis in conditional statements to follow the repository's Swift Style Guide.
1 parent 11fcad7 commit 15d2778

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Singly Linked List/SinglyLinkedList.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,19 @@ public struct SinglyLinkedList<T> {
125125
var i = 0
126126
var elementToDelete: SinglyLinkedListNode<T>
127127

128-
while (i < index) {
128+
while i < index {
129129
previous = current
130130
current = current?.next
131131
i += 1
132132
}
133133

134134
// Current is now the element to delete (at index position.tag)
135135
elementToDelete = current!
136-
if (storage.head === current) {
136+
if storage.head === current {
137137
storageForWritting.head = current?.next
138138
}
139139

140-
if (storage.tail === current) {
140+
if storage.tail === current {
141141
storageForWritting.tail = previous
142142
}
143143

@@ -164,7 +164,7 @@ public struct SinglyLinkedList<T> {
164164

165165
let i = (count - kthToLast)
166166

167-
if (i == 0) {
167+
if i == 0 {
168168
return node
169169
}
170170

@@ -243,7 +243,7 @@ private extension SinglyLinkedList {
243243
// Iterate through current list of nodes and copy them.
244244
var current: SinglyLinkedListNode<T>? = storage.head?.next
245245

246-
while (current != nil) {
246+
while current != nil {
247247
// Create a copy
248248
let currentCopy = SinglyLinkedListNode<T>(value: current!.value)
249249

@@ -283,11 +283,11 @@ extension SinglyLinkedList where T: Comparable {
283283

284284
if let foundNode = current {
285285

286-
if (storage.head === foundNode) {
286+
if storage.head === foundNode {
287287
storageForWritting.head = foundNode.next
288288
}
289289

290-
if (storage.tail === foundNode) {
290+
if storage.tail === foundNode {
291291
storage.tail = previous
292292
}
293293

@@ -303,18 +303,18 @@ extension SinglyLinkedList where T: Comparable {
303303
// Copy on write: this updates storage if necessary.
304304
var current = storageForWritting.head
305305

306-
while (current != nil) {
306+
while current != nil {
307307
var previous: SinglyLinkedListNode<T>? = current
308308
var next = current?.next
309309

310-
while (next != nil) {
311-
if (current?.value == next?.value) {
310+
while next != nil {
311+
if current?.value == next?.value {
312312

313-
if (storage.head === next) {
313+
if storage.head === next {
314314
storage.head = next?.next
315315
}
316316

317-
if (storage.tail === next) {
317+
if storage.tail === next {
318318
storage.tail = previous
319319
}
320320

@@ -461,7 +461,7 @@ func findTail<T>(in node: SinglyLinkedListNode<T>) -> (tail: SinglyLinkedListNod
461461
var current: SinglyLinkedListNode<T>? = node
462462
var count = 1
463463

464-
while (current?.next != nil) {
464+
while current?.next != nil {
465465
current = current?.next
466466
count += 1
467467
}

0 commit comments

Comments
 (0)