We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8008a24 commit 0598dc1Copy full SHA for 0598dc1
Treap/TreapCollectionType.swift
@@ -62,14 +62,18 @@ extension Treap: CollectionType {
62
}
63
64
65
-public struct TreapIndex<Key: Comparable>: ForwardIndexType {
+public struct TreapIndex<Key: Comparable>: BidirectionalIndexType {
66
private let keys: [Key]
67
private let keyIndex: Int
68
69
public func successor() -> TreapIndex {
70
return TreapIndex(keys: keys, keyIndex: keyIndex + 1)
71
72
73
+ public func predecessor() -> TreapIndex {
74
+ return TreapIndex(keys: keys, keyIndex: keyIndex - 1)
75
+ }
76
+
77
private init(keys: [Key] = [], keyIndex: Int = 0) {
78
self.keys = keys
79
self.keyIndex = keyIndex
0 commit comments