@@ -75,8 +75,8 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
75
75
- returns: String
76
76
*/
77
77
public var description : String {
78
- var output : String = " [ "
79
- let l : Int = count - 1
78
+ var output = " [ "
79
+ let l = count - 1
80
80
for i in 0 ..< count {
81
81
output += " \( self [ i] ) "
82
82
if i != l {
@@ -119,7 +119,7 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
119
119
120
120
/**
121
121
:name: startIndex
122
- :description: Conforms to the CollectionType Protocol.
122
+ :description: Conforms to the Collection Protocol.
123
123
- returns: Int
124
124
*/
125
125
public var startIndex : Int {
@@ -128,7 +128,7 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
128
128
129
129
/**
130
130
:name: endIndex
131
- :description: Conforms to the CollectionType Protocol.
131
+ :description: Conforms to the Collection Protocol.
132
132
- returns: Int
133
133
*/
134
134
public var endIndex : Int {
@@ -212,7 +212,7 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
212
212
/**
213
213
The probability of elements.
214
214
*/
215
- public func probability( _ block: ( Key , Value ? ) -> Bool ) -> Double {
215
+ public func probability( execute block: ( Key , Value ? ) -> Bool ) -> Double {
216
216
if 0 == count {
217
217
return 0
218
218
}
@@ -246,7 +246,7 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
246
246
- returns: Bool
247
247
*/
248
248
@discardableResult
249
- mutating public func insert( _ key : Key , value : Value ? ) -> Bool {
249
+ mutating public func insert( value : Value ? , for key : Key ) -> Bool {
250
250
return sentinel !== internalInsert ( key, value: value)
251
251
}
252
252
@@ -255,18 +255,18 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
255
255
:description: Inserts a list of (Key, Value?) pairs.
256
256
- parameter nodes: (Key, Value?)... Elements to insert.
257
257
*/
258
- mutating public func insert( _ nodes: ( Key , Value ? ) ... ) {
259
- insert ( nodes)
258
+ mutating public func insert( nodes: ( Key , Value ? ) ... ) {
259
+ insert ( nodes : nodes)
260
260
}
261
261
262
262
/**
263
263
:name: insert
264
264
:description: Inserts an array of (Key, Value?) pairs.
265
- - parameter nodes: Array< (Key, Value?)> Elements to insert.
265
+ - parameter nodes: [ (Key, Value?)] Elements to insert.
266
266
*/
267
- mutating public func insert( _ nodes: Array < ( Key , Value ? ) > ) {
267
+ mutating public func insert( nodes: [ ( Key , Value ? ) ] ) {
268
268
for (k, v) in nodes {
269
- insert ( k , value: v)
269
+ insert ( value: v, for : k )
270
270
}
271
271
}
272
272
@@ -277,8 +277,8 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
277
277
the given key value will be removed.
278
278
- returns: RedBlackTree<Key, Value>?
279
279
*/
280
- mutating public func removeValueForKeys ( _ keys: Key ... ) {
281
- return removeValueForKeys ( keys)
280
+ mutating public func removeValue ( for keys: Key ... ) {
281
+ return removeValue ( for : keys)
282
282
}
283
283
284
284
/**
@@ -288,7 +288,7 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
288
288
the given key will be removed.
289
289
- returns: RedBlackTree<Key, Value>?
290
290
*/
291
- mutating public func removeValueForKeys ( _ keys: Array < Key > ) {
291
+ mutating public func removeValue ( for keys: [ Key ] ) {
292
292
for x in keys {
293
293
var z = internalRemoveValueForKey ( x)
294
294
while sentinel !== z {
@@ -324,8 +324,8 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
324
324
If the tree allows non-unique keys, then all keys matching
325
325
the given key value will be updated.
326
326
*/
327
- mutating public func updateValue ( _ value: Value ? , forKey : Key ) {
328
- internalUpdateValue ( value, forKey: forKey , node: root)
327
+ mutating public func update ( value: Value ? , for key : Key ) {
328
+ internalUpdateValue ( value, forKey: key , node: root)
329
329
}
330
330
331
331
/**
@@ -334,7 +334,7 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
334
334
in isUniquelyKeyed tree of a given keyed node.
335
335
- returns: Value?
336
336
*/
337
- public func findValueForKey ( _ key: Key ) -> Value ? {
337
+ public func findValue ( for key: Key ) -> Value ? {
338
338
return internalFindNodeForKey ( key) . value
339
339
}
340
340
@@ -381,7 +381,7 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
381
381
:description: Returns the Index of a given member, or nil if the member is not present in the set.
382
382
- returns: Int
383
383
*/
384
- public func indexOf ( _ key: Key ) -> Int {
384
+ public func index ( of key: Key ) -> Int {
385
385
let x = internalFindNodeForKey ( key)
386
386
return sentinel == x ? - 1 : internalOrder ( x) - 1
387
387
}
0 commit comments