作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是 SequenceType
的 Generator
需要生产 Elements
顺序与 Index
相同successor()
?也就是说,以下条件必须适用于所有集合/序列类型吗?
let str = "Hello!"
var dex = str.startIndex
var gen = str.generate()
while dex != str.endIndex {
assert (str[dex] == gen.next())
dex = dex.successor()
}
显然是 IndexingGenerator<>
将具有此属性,但必须全部 Generators
?
最佳答案
答案是肯定的。定义 CollectionType
的 Swift 代码中的注释是:
/// The sequence view of the elements is identical to the collection
/// view. In other words, the following code binds the same series of
/// values to `x` as does `for x in self {}`::
///
/// for i in startIndex..<endIndex {
/// let x = self[i]
/// }
由于for x in self
调用了GeneratorType
接口(interface),因此通过这两个接口(interface)生成的订单必须相同。新 CollectionTypes 的实现者,充其量似乎是以此为指导。
关于swift - CollectionType 索引跟踪相应的 SequenceType 生成器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29641023/
我在 Java 中遇到异常处理问题,这是我的代码。当我尝试运行此行时出现编译器错误:throw new MojException("Bledne dane");。错误是: exception MojE
我刚刚开始学习asp.net。在你们的支持下,我希望我能从这个论坛学到更多东西。 我的问题是, 我在 asp.net 页面中有一个 TabContainer1,因为每个选项卡面板中有多个类似 (60)
我是一名优秀的程序员,十分优秀!