Skip to content

Commit 4f8becb

Browse files
author
318236213
committed
removed redundant code
1 parent 506dbcf commit 4f8becb

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

Ordered Set/OrderedSet.playground/Contents.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,7 @@ public struct OrderedSet<T: Comparable> {
7777
if exists(item) {
7878
return // don't add an item if it already exists
7979
}
80-
81-
// if the set is initially empty, we need to simply append the item to internalSet
82-
if count == 0 {
83-
internalSet.append(item)
84-
return
85-
}
86-
80+
8781
for i in 0..<count {
8882
if internalSet[i] > item {
8983
internalSet.insert(item, atIndex: i)
@@ -260,6 +254,3 @@ print(repeatedSet.findIndex(Player(name: "Player 5", points: 1000)))
260254

261255

262256

263-
264-
265-

Ordered Set/OrderedSet.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ public struct OrderedSet<T: Comparable> {
1919
return // don't add an item if it already exists
2020
}
2121

22-
// if the set is initially empty, we need to simply append the item to internalSet
23-
if count == 0 {
24-
internalSet.append(item)
25-
return
26-
}
27-
2822
for i in 0..<count {
2923
if internalSet[i] > item {
3024
internalSet.insert(item, atIndex: i)

0 commit comments

Comments
 (0)