title: Filter & Map over a Swift Dictionary?
body: <p>I have two methods doing the same thing, one using the more functional Swift.</p>
  
  <pre><code>  func getConstraints1(forState newState: State) -&gt; (on: [NSLayoutConstraint], off: [NSLayoutConstraint]) {
      return (
        constraints.filter { $0.key.rawValue == newState.rawValue }.map { $1 }.first!,
        constraints.filter { $0.key.rawValue != newState.rawValue }.map { $1 }.first!
      )
    }
  </code></pre>
  
  <p>The other one using a standard procedural approach.</p>
  
  <pre><code>func getConstraints2(for nextState: State) -&gt; (on: [NSLayoutConstraint], off: [NSLayoutConstraint]) {
      var on = [NSLayoutConstraint]()
      var off = [NSLayoutConstraint]()
  
      for (state, constraints) in constraints {
        if state == nextState {
          on += constraints
        } else {
          off += constraints
        }
      }
  
      return (on, off)
    }
  </code></pre>
  
  <p>I feel like <code>getConstraints2</code> is going to be faster than <code>getConstraints1</code>, but I like the syntax in <code>getConstraints1</code>. Is there ever a case fort doing filter/map/reduce operations on a Dictionary? Is this it?</p>