Why is endIndex one greater than the last valid subscript argument, rather than 
simply the last valid subscript argument? I’m sure there are great reasons for 
this, but I just can’t think of them myself.

I’m implementing a binary tree and I want to implement BidirectionalCollection. 
Each index contains a (private) reference to the corresponding node in the 
tree. However, endIndex shouldn’t point to anything, and it makes things very 
complicated if I want a constant time implementation of index(before:). How are 
we supposed to deal with endIndex if the index is something more complex than a 
simple integer?
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to