0001    /// :nodoc:
0002    public struct ComboGen
Combinations.swift:28
  public func generate() -> ComboGen<Element> {
Combinations.swift:29
    return ComboGen<Element>(coll: col, curr: start, inds: inds)
<SubElement
Combinations.swift:4
  private let coll: [SubElement]
Combinations.swift:5
  private var curr: [SubElement]
Combinations.swift:8
  mutating public func next() -> [SubElement]? {
> : GeneratorType { 0003 0004 private let coll
Combinations.swift:9
    for (max, curInd) in zip(coll.indices.reverse(), inds.indices.reverse())
Combinations.swift:11
        curr[curInd] = coll[++inds[curInd]]
Combinations.swift:14
          curr[j] = coll[inds[j]]
: [SubElement] 0005 private var curr
Combinations.swift:11
        curr[curInd] = coll[++inds[curInd]]
Combinations.swift:14
          curr[j] = coll[inds[j]]
Combinations.swift:16
        return curr
: [SubElement] 0006 private var inds
Combinations.swift:10
      where max != inds[curInd] {
Combinations.swift:9
    for (max, curInd) in zip(coll.indices.reverse(), inds.indices.reverse())
Combinations.swift:11
        curr[curInd] = coll[++inds[curInd]]
Combinations.swift:12
        for j in inds.indices.suffixFrom(curInd+1) {
Combinations.swift:13
          inds[j] = inds[j-1].successor()
Combinations.swift:13
          inds[j] = inds[j-1].successor()
Combinations.swift:14
          curr[j] = coll[inds[j]]
: [Int] 0007 /// :nodoc: 0008 mutating public func next() -> [SubElement]? { 0009 for (max, curInd) in zip(coll.indices.reverse(), inds.indices.reverse()) 0010 where max != inds[curInd] { 0011 curr[curInd] = coll[++inds[curInd]] 0012 for j in inds.indices.suffixFrom(curInd+1) { 0013 inds[j] = inds[j-1].successor() 0014 curr[j] = coll[inds[j]] 0015 } 0016 return curr 0017 } 0018 return nil 0019 } 0020 } 0021 /// :nodoc: 0022 public struct ComboSeq
Combinations.swift:89
    return Array(ComboSeq(n: n, col: Array(self)))
Combinations.swift:103
  public func lazyCombos(n: Int) -> ComboSeq<Generator.Element> {
Combinations.swift:104
    return ComboSeq(n: n, col: Array(self))
<Element
Combinations.swift:24
  private let start: [Element]
Combinations.swift:25
  private let col  : [Element]
Combinations.swift:28
  public func generate() -> ComboGen<Element> {
Combinations.swift:29
    return ComboGen<Element>(coll: col, curr: start, inds: inds)
Combinations.swift:32
  internal init(n: Int, col: [Element]) {
> : LazySequenceType { 0023 0024 private let start
Combinations.swift:29
    return ComboGen<Element>(coll: col, curr: start, inds: inds)
Combinations.swift:34
    start = Array(col.prefixUpTo(n))
: [Element] 0025 private let col
Combinations.swift:29
    return ComboGen<Element>(coll: col, curr: start, inds: inds)
Combinations.swift:33
    self.col = col
: [Element] 0026 private let inds
Combinations.swift:29
    return ComboGen<Element>(coll: col, curr: start, inds: inds)
Combinations.swift:37
    self.inds = inds
: [Int] 0027 /// :nodoc: 0028 public func generate() -> ComboGen<Element> { 0029 return ComboGen<Element>(coll: col, curr: start, inds: inds) 0030 } 0031 0032 internal init
Combinations.swift:89
    return Array(ComboSeq(n: n, col: Array(self)))
Combinations.swift:104
    return ComboSeq(n: n, col: Array(self))
(n: Int, col: [Element]) { 0033 self.col = col 0034 start = Array(col.prefixUpTo(n)) 0035 var inds = Array(col.indices.prefixUpTo(n)) 0036 if !inds.isEmpty { --inds[n.predecessor()] } 0037 self.inds = inds 0038 } 0039 } 0040 /// :nodoc: 0041 public struct ComboRepGen
Combinations.swift:68
  public func generate() -> ComboRepGen<Element> {
Combinations.swift:69
    return ComboRepGen(coll: col, curr: start, inds: inds, max: max)
<Element
Combinations.swift:43
  private let coll: [Element]
Combinations.swift:44
  private var curr: [Element]
Combinations.swift:48
  mutating public func next() -> [Element]? {
> : GeneratorType { 0042 0043 private let coll
Combinations.swift:50
      curr[curInd] = coll[++inds[curInd]]
Combinations.swift:53
        curr[j] = coll[inds[j]]
: [Element] 0044 private var curr
Combinations.swift:50
      curr[curInd] = coll[++inds[curInd]]
Combinations.swift:53
        curr[j] = coll[inds[j]]
Combinations.swift:55
      return curr
: [Element] 0045 private var inds
Combinations.swift:49
    for curInd in inds.indices.reverse() where max != inds[curInd] {
Combinations.swift:49
    for curInd in inds.indices.reverse() where max != inds[curInd] {
Combinations.swift:50
      curr[curInd] = coll[++inds[curInd]]
Combinations.swift:51
      for j in (curInd+1)..<inds.count {
Combinations.swift:52
        inds[j] = inds[j-1]
Combinations.swift:52
        inds[j] = inds[j-1]
Combinations.swift:53
        curr[j] = coll[inds[j]]
: [Int] 0046 private let max
Combinations.swift:49
    for curInd in inds.indices.reverse() where max != inds[curInd] {
: Int 0047 /// :nodoc: 0048 mutating public func next() -> [Element]? { 0049 for curInd in inds.indices.reverse() where max != inds[curInd] { 0050 curr[curInd] = coll[++inds[curInd]] 0051 for j in (curInd+1)..<inds.count { 0052 inds[j] = inds[j-1] 0053 curr[j] = coll[inds[j]] 0054 } 0055 return curr 0056 } 0057 return nil 0058 } 0059 } 0060 /// :nodoc: 0061 public struct ComboRepSeq
Combinations.swift:96
    return Array(ComboRepSeq(n: n, col: Array(self)))
Combinations.swift:111
  public func lazyCombosWithRep(n: Int) -> ComboRepSeq<Generator.Element> {
Combinations.swift:112
    return ComboRepSeq(n: n, col: Array(self))
<Element
Combinations.swift:63
  private let start: [Element]
Combinations.swift:65
  private let col  : [Element]
Combinations.swift:68
  public func generate() -> ComboRepGen<Element> {
Combinations.swift:72
  internal init(n: Int, col: [Element]) {
> : LazySequenceType { 0062 0063 private let start
Combinations.swift:69
    return ComboRepGen(coll: col, curr: start, inds: inds, max: max)
Combinations.swift:74
    start = col.first.map { x in Array(count: n, repeatedValue: x) } ?? []
: [Element] 0064 private let inds
Combinations.swift:69
    return ComboRepGen(coll: col, curr: start, inds: inds, max: max)
Combinations.swift:77
    self.inds = inds
: [Int] 0065 private let col
Combinations.swift:69
    return ComboRepGen(coll: col, curr: start, inds: inds, max: max)
Combinations.swift:73
    self.col = col
: [Element] 0066 private let max
Combinations.swift:69
    return ComboRepGen(coll: col, curr: start, inds: inds, max: max)
Combinations.swift:78
    max = col.endIndex.predecessor()
: Int 0067 /// :nodoc: 0068 public func generate() -> ComboRepGen<Element> { 0069 return ComboRepGen(coll: col, curr: start, inds: inds, max: max) 0070 } 0071 0072 internal init
Combinations.swift:96
    return Array(ComboRepSeq(n: n, col: Array(self)))
Combinations.swift:112
    return ComboRepSeq(n: n, col: Array(self))
(n: Int, col: [Element]) { 0073 self.col = col 0074 start = col.first.map { x in Array(count: n, repeatedValue: x) } ?? [] 0075 var inds = Array(count: n, repeatedValue: col.startIndex) 0076 if !inds.isEmpty { --inds[n-1] } 0077 self.inds = inds 0078 max = col.endIndex.predecessor() 0079 } 0080 } 0081 0082 0083 extension SequenceType { 0084 /** 0085 Returns the combinations without repetition of length `n` of `self` 0086 */ 0087 @warn_unused_result 0088 public func combos(n: Int) -> [[Generator.Element]] { 0089 return Array(ComboSeq(n: n, col: Array(self))) 0090 } 0091 /** 0092 Returns the combinations with repetition of length `n` of `self` 0093 */ 0094 @warn_unused_result 0095 public func combosWithRep(n: Int) -> [[Generator.Element]] { 0096 return Array(ComboRepSeq(n: n, col: Array(self))) 0097 } 0098 /** 0099 Returns the combinations without repetition of length `n` of `self`, generated lazily 0100 and on-demand 0101 */ 0102 @warn_unused_result 0103 public func lazyCombos
Permutations.swift:118
    return Array(lazyCombos(n).flatMap { a in a.permutations() })
(n: Int) -> ComboSeq<Generator.Element> { 0104 return ComboSeq(n: n, col: Array(self)) 0105 } 0106 /** 0107 Returns the combinations with repetition of length `n` of `self`, generated lazily and 0108 on-demand 0109 */ 0110 @warn_unused_result 0111 public func lazyCombosWithRep(n: Int) -> ComboRepSeq<Generator.Element> { 0112 return ComboRepSeq(n: n, col: Array(self)) 0113 } 0114 }