Skip to content

Commit 1453ec5

Browse files
author
Daniel Dahan
committed
development: progression commit for refactoring DoublyLinkedList
1 parent 9df032e commit 1453ec5

13 files changed

+229
-267
lines changed

Algorithm.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
65744CF51C554EDA0011C977 /* DoublyLinkedListNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65744CE11C554EDA0011C977 /* DoublyLinkedListNode.swift */; };
2323
65744CF61C554EDA0011C977 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 65744CE21C554EDA0011C977 /* LICENSE */; };
2424
65744CF71C554EDA0011C977 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 65744CE21C554EDA0011C977 /* LICENSE */; };
25-
65744CF81C554EDA0011C977 /* ProbableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65744CE31C554EDA0011C977 /* ProbableType.swift */; };
26-
65744CF91C554EDA0011C977 /* ProbableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65744CE31C554EDA0011C977 /* ProbableType.swift */; };
25+
65744CF81C554EDA0011C977 /* Probable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65744CE31C554EDA0011C977 /* Probable.swift */; };
26+
65744CF91C554EDA0011C977 /* Probable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65744CE31C554EDA0011C977 /* Probable.swift */; };
2727
65744CFA1C554EDA0011C977 /* Queue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65744CE41C554EDA0011C977 /* Queue.swift */; };
2828
65744CFB1C554EDA0011C977 /* Queue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65744CE41C554EDA0011C977 /* Queue.swift */; };
2929
65744CFC1C554EDA0011C977 /* RedBlackNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65744CE51C554EDA0011C977 /* RedBlackNode.swift */; };
@@ -65,7 +65,7 @@
6565
65744D2A1C554F2E0011C977 /* Deque.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CDF1C554EDA0011C977 /* Deque.swift */; settings = {ATTRIBUTES = (Public, ); }; };
6666
65744D2B1C554F2E0011C977 /* DoublyLinkedList.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE01C554EDA0011C977 /* DoublyLinkedList.swift */; settings = {ATTRIBUTES = (Public, ); }; };
6767
65744D2C1C554F2E0011C977 /* DoublyLinkedListNode.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE11C554EDA0011C977 /* DoublyLinkedListNode.swift */; settings = {ATTRIBUTES = (Public, ); }; };
68-
65744D2D1C554F2E0011C977 /* ProbableType.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE31C554EDA0011C977 /* ProbableType.swift */; settings = {ATTRIBUTES = (Public, ); }; };
68+
65744D2D1C554F2E0011C977 /* Probable.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE31C554EDA0011C977 /* Probable.swift */; settings = {ATTRIBUTES = (Public, ); }; };
6969
65744D2E1C554F2E0011C977 /* Queue.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE41C554EDA0011C977 /* Queue.swift */; settings = {ATTRIBUTES = (Public, ); }; };
7070
65744D2F1C554F2E0011C977 /* RedBlackNode.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE51C554EDA0011C977 /* RedBlackNode.swift */; settings = {ATTRIBUTES = (Public, ); }; };
7171
65744D301C554F2E0011C977 /* RedBlackTree.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE61C554EDA0011C977 /* RedBlackTree.swift */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -80,7 +80,7 @@
8080
65744D391C554F400011C977 /* Deque.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CDF1C554EDA0011C977 /* Deque.swift */; settings = {ATTRIBUTES = (Public, ); }; };
8181
65744D3A1C554F410011C977 /* DoublyLinkedList.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE01C554EDA0011C977 /* DoublyLinkedList.swift */; settings = {ATTRIBUTES = (Public, ); }; };
8282
65744D3B1C554F410011C977 /* DoublyLinkedListNode.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE11C554EDA0011C977 /* DoublyLinkedListNode.swift */; settings = {ATTRIBUTES = (Public, ); }; };
83-
65744D3C1C554F410011C977 /* ProbableType.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE31C554EDA0011C977 /* ProbableType.swift */; settings = {ATTRIBUTES = (Public, ); }; };
83+
65744D3C1C554F410011C977 /* Probable.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE31C554EDA0011C977 /* Probable.swift */; settings = {ATTRIBUTES = (Public, ); }; };
8484
65744D3D1C554F410011C977 /* Queue.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE41C554EDA0011C977 /* Queue.swift */; settings = {ATTRIBUTES = (Public, ); }; };
8585
65744D3E1C554F410011C977 /* RedBlackNode.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE51C554EDA0011C977 /* RedBlackNode.swift */; settings = {ATTRIBUTES = (Public, ); }; };
8686
65744D3F1C554F410011C977 /* RedBlackTree.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65744CE61C554EDA0011C977 /* RedBlackTree.swift */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -122,7 +122,7 @@
122122
65744CE01C554EDA0011C977 /* DoublyLinkedList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoublyLinkedList.swift; sourceTree = "<group>"; };
123123
65744CE11C554EDA0011C977 /* DoublyLinkedListNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoublyLinkedListNode.swift; sourceTree = "<group>"; };
124124
65744CE21C554EDA0011C977 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
125-
65744CE31C554EDA0011C977 /* ProbableType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProbableType.swift; sourceTree = "<group>"; };
125+
65744CE31C554EDA0011C977 /* Probable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Probable.swift; sourceTree = "<group>"; };
126126
65744CE41C554EDA0011C977 /* Queue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Queue.swift; sourceTree = "<group>"; };
127127
65744CE51C554EDA0011C977 /* RedBlackNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedBlackNode.swift; sourceTree = "<group>"; };
128128
65744CE61C554EDA0011C977 /* RedBlackTree.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedBlackTree.swift; sourceTree = "<group>"; };
@@ -208,7 +208,7 @@
208208
65744CDF1C554EDA0011C977 /* Deque.swift */,
209209
65744CE01C554EDA0011C977 /* DoublyLinkedList.swift */,
210210
65744CE11C554EDA0011C977 /* DoublyLinkedListNode.swift */,
211-
65744CE31C554EDA0011C977 /* ProbableType.swift */,
211+
65744CE31C554EDA0011C977 /* Probable.swift */,
212212
65744CE41C554EDA0011C977 /* Queue.swift */,
213213
65744CE51C554EDA0011C977 /* RedBlackNode.swift */,
214214
65744CE61C554EDA0011C977 /* RedBlackTree.swift */,
@@ -251,7 +251,7 @@
251251
65744D2A1C554F2E0011C977 /* Deque.swift in Headers */,
252252
65744D2B1C554F2E0011C977 /* DoublyLinkedList.swift in Headers */,
253253
65744D2C1C554F2E0011C977 /* DoublyLinkedListNode.swift in Headers */,
254-
65744D2D1C554F2E0011C977 /* ProbableType.swift in Headers */,
254+
65744D2D1C554F2E0011C977 /* Probable.swift in Headers */,
255255
65744D2E1C554F2E0011C977 /* Queue.swift in Headers */,
256256
65744D2F1C554F2E0011C977 /* RedBlackNode.swift in Headers */,
257257
65744D301C554F2E0011C977 /* RedBlackTree.swift in Headers */,
@@ -274,7 +274,7 @@
274274
65744D391C554F400011C977 /* Deque.swift in Headers */,
275275
65744D3A1C554F410011C977 /* DoublyLinkedList.swift in Headers */,
276276
65744D3B1C554F410011C977 /* DoublyLinkedListNode.swift in Headers */,
277-
65744D3C1C554F410011C977 /* ProbableType.swift in Headers */,
277+
65744D3C1C554F410011C977 /* Probable.swift in Headers */,
278278
65744D3D1C554F410011C977 /* Queue.swift in Headers */,
279279
65744D3E1C554F410011C977 /* RedBlackNode.swift in Headers */,
280280
65744D3F1C554F410011C977 /* RedBlackTree.swift in Headers */,
@@ -456,7 +456,7 @@
456456
65744CF41C554EDA0011C977 /* DoublyLinkedListNode.swift in Sources */,
457457
65744CFE1C554EDA0011C977 /* RedBlackTree.swift in Sources */,
458458
65744CF01C554EDA0011C977 /* Deque.swift in Sources */,
459-
65744CF81C554EDA0011C977 /* ProbableType.swift in Sources */,
459+
65744CF81C554EDA0011C977 /* Probable.swift in Sources */,
460460
65744CF21C554EDA0011C977 /* DoublyLinkedList.swift in Sources */,
461461
65744D041C554EDA0011C977 /* SortedMultiSet.swift in Sources */,
462462
);
@@ -494,7 +494,7 @@
494494
65744CF51C554EDA0011C977 /* DoublyLinkedListNode.swift in Sources */,
495495
65744CFF1C554EDA0011C977 /* RedBlackTree.swift in Sources */,
496496
65744CF11C554EDA0011C977 /* Deque.swift in Sources */,
497-
65744CF91C554EDA0011C977 /* ProbableType.swift in Sources */,
497+
65744CF91C554EDA0011C977 /* Probable.swift in Sources */,
498498
65744CF31C554EDA0011C977 /* DoublyLinkedList.swift in Sources */,
499499
65744D051C554EDA0011C977 /* SortedMultiSet.swift in Sources */,
500500
);

Sources/Algorithm+Array.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extension Array where Element: Equatable {
6666
}
6767
}
6868

69-
extension Array: ProbableType {
69+
extension Array: Probable {
7070
/**
7171
The total count for the given Elements.
7272
- Parameter of elements: A list of Elements.
@@ -137,8 +137,8 @@ extension Array: ProbableType {
137137
- Parameter elements: A list of Elements.
138138
- Returns: A Double.
139139
*/
140-
public func expectedValue<Element: Equatable>(trials: Int, elements: Element...) -> Double {
141-
return expectedValue(trials: trials, elements: elements)
140+
public func expectedValue<Element: Equatable>(of trials: Int, for elements: Element...) -> Double {
141+
return expectedValue(of: trials, for: elements)
142142
}
143143

144144
/**
@@ -147,7 +147,7 @@ extension Array: ProbableType {
147147
- Parameter elements: An Array of Elements.
148148
- Returns: A Double.
149149
*/
150-
public func expectedValue<Element: Equatable>(trials: Int, elements: [Element]) -> Double {
150+
public func expectedValue<Element: Equatable>(of trials: Int, for elements: [Element]) -> Double {
151151
return Double(trials) * probability(of: elements)
152152
}
153153
}

Sources/Algorithm+Set.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
extension Set: ProbableType {
31+
extension Set: Probable {
3232
/**
3333
The total count for the given Elements.
3434
- Parameter of elements: A list of Elements.
@@ -99,8 +99,8 @@ extension Set: ProbableType {
9999
- Parameter elements: A list of Elements.
100100
- Returns: A Double.
101101
*/
102-
public func expectedValue<Element: Equatable>(trials: Int, elements: Element...) -> Double {
103-
return expectedValue(trials: trials, elements: elements)
102+
public func expectedValue<Element: Equatable>(of trials: Int, for elements: Element...) -> Double {
103+
return expectedValue(of: trials, for: elements)
104104
}
105105

106106
/**
@@ -109,7 +109,7 @@ extension Set: ProbableType {
109109
- Parameter elements: An Array of Elements.
110110
- Returns: A Double.
111111
*/
112-
public func expectedValue<Element: Equatable>(trials: Int, elements: [Element]) -> Double {
112+
public func expectedValue<Element: Equatable>(of trials: Int, for elements: [Element]) -> Double {
113113
return Double(trials) * probability(of: elements)
114114
}
115115
}

Sources/Deque.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ public struct Deque<Element>: CustomStringConvertible, Sequence {
9393
list = DoublyLinkedList<Element>()
9494
}
9595

96-
//
97-
// :name: generate
98-
// :description: Conforms to the SequenceType Protocol. Returns
99-
// the next value in the sequence of nodes.
100-
// :returns: Deque.Generator
101-
//
102-
public func makeIterator() -> Deque.Iterator {
96+
/**
97+
Conforms to the SequenceType Protocol. Returns the next value
98+
in the sequence of nodes.
99+
- Returns: A Deque.Iterator.
100+
*/
101+
public func makeIterator() -> Deque.Iterator {
103102
return list.makeIterator()
104103
}
105104

@@ -108,7 +107,7 @@ public struct Deque<Element>: CustomStringConvertible, Sequence {
108107
:description: Insert a new element at the front of the Deque.
109108
*/
110109
mutating public func insert(atFront element: Element) {
111-
list.insertAtFront(element)
110+
list.insert(atFront: element)
112111
}
113112

114113
/**
@@ -126,7 +125,7 @@ public struct Deque<Element>: CustomStringConvertible, Sequence {
126125
:description: Insert a new element at the back of the Deque.
127126
*/
128127
mutating public func insert(atBack element: Element) {
129-
list.insertAtBack(element)
128+
list.insert(atBack: element)
130129
}
131130

132131
/**
@@ -143,7 +142,7 @@ public struct Deque<Element>: CustomStringConvertible, Sequence {
143142
:name: removeAll
144143
:description: Remove all elements from the Deque.
145144
*/
146-
public func removeAll() {
145+
mutating public func removeAll() {
147146
list.removeAll()
148147
}
149148
}

0 commit comments

Comments
 (0)