Skip to content

Commit a784adb

Browse files
author
Daniel Dahan
committed
development: updated RedBlackTree to structs
1 parent 73ff809 commit a784adb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Sources/RedBlackTree.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,14 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
402402
while x !== sentinel {
403403
y = x
404404
y.order += 1
405-
x = key < x.key ? x.left : x.right
405+
x = key < x.key as Key ? x.left : x.right
406406
}
407407

408408
let z = RedBlackNode<Key, Value>(parent: y, sentinel: sentinel, key: key, value: value)
409409

410410
if y == sentinel {
411411
root = z
412-
} else if key < y.key {
412+
} else if key < y.key as Key {
413413
y.left = z
414414
} else {
415415
y.right = z
@@ -694,7 +694,7 @@ public struct RedBlackTree<Key: Comparable, Value>: Probable, Collection, Custom
694694
if key == z.key {
695695
return z
696696
}
697-
z = key < z.key ? z.left : z.right
697+
z = key < z.key as Key ? z.left : z.right
698698
}
699699
return sentinel
700700
}
@@ -788,27 +788,27 @@ public func !=<Key : Comparable, Value>(lhs: RedBlackTree<Key, Value>, rhs: RedB
788788
public func +<Key : Comparable, Value>(lhs: RedBlackTree<Key, Value>, rhs: RedBlackTree<Key, Value>) -> RedBlackTree<Key, Value> {
789789
var t = lhs
790790
for (k, v) in rhs {
791-
t.insert(k, value: v)
791+
t.insert(value: v, for: k)
792792
}
793793
return t
794794
}
795795

796796
public func +=<Key : Comparable, Value>(lhs: inout RedBlackTree<Key, Value>, rhs: RedBlackTree<Key, Value>) {
797797
for (k, v) in rhs {
798-
lhs.insert(k, value: v)
798+
lhs.insert(value: v, for: k)
799799
}
800800
}
801801

802802
public func -<Key : Comparable, Value>(lhs: RedBlackTree<Key, Value>, rhs: RedBlackTree<Key, Value>) -> RedBlackTree<Key, Value> {
803803
var t = rhs
804804
for (k, _) in rhs {
805-
t.removeValueForKeys(k)
805+
t.removeValue(for: k)
806806
}
807807
return t
808808
}
809809

810810
public func -=<Key : Comparable, Value>(lhs: inout RedBlackTree<Key, Value>, rhs: RedBlackTree<Key, Value>) {
811811
for (k, _) in rhs {
812-
lhs.removeValueForKeys(k)
812+
lhs.removeValue(for: k)
813813
}
814814
}

0 commit comments

Comments
 (0)