Skip to content

Commit 0598dc1

Browse files
author
Robert Thompson
committed
May as well be BidirectionalIndexType
1 parent 8008a24 commit 0598dc1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Treap/TreapCollectionType.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,18 @@ extension Treap: CollectionType {
6262
}
6363
}
6464

65-
public struct TreapIndex<Key: Comparable>: ForwardIndexType {
65+
public struct TreapIndex<Key: Comparable>: BidirectionalIndexType {
6666
private let keys: [Key]
6767
private let keyIndex: Int
6868

6969
public func successor() -> TreapIndex {
7070
return TreapIndex(keys: keys, keyIndex: keyIndex + 1)
7171
}
7272

73+
public func predecessor() -> TreapIndex {
74+
return TreapIndex(keys: keys, keyIndex: keyIndex - 1)
75+
}
76+
7377
private init(keys: [Key] = [], keyIndex: Int = 0) {
7478
self.keys = keys
7579
self.keyIndex = keyIndex

0 commit comments

Comments
 (0)