logo
  • 教程列表
  • SO官方文档
  • 集
    • 声明集
    • 对集合执行操作
    • CountedSet
    • 修改集合中的值
    • 检查集合是否包含值
    • 将我自己的类型的值添加到 Set
  1. StackOverflow 文档
  2. Swift Language 教程
  3. 集
  4. CountedSet

CountedSet

Created: November-22, 2018

Version = 3.0

Swift 3 引入了 CountedSet 类(它是 NSCountedSet Objective-C 类的 Swift 版本)。

如名称所示,CountedSet 会跟踪值的存在次数。

let countedSet = CountedSet()
countedSet.add(1)
countedSet.add(1)
countedSet.add(1)
countedSet.add(2)

countedSet.count(for: 1) // 3
countedSet.count(for: 2) // 1
  • 修改集合中的值
  • 对集合执行操作

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明