<commit_before># ConcurrentMap

We all love Array.map in Swift.
Now you can speed it up by using multiple threads. Like boss.

## Why?

The question is more like, why is this not in the standard library by default :P.

## How?

      // specify the threads
      let newArray = array.concurrentMap({ pureFunction($0) }, threads: 2)
      
      // or just leave it, the default is 4!
      let newArray = array.concurrentMap { pureFunction($0) }
      
## Warning

Only use concurrentMap with pure functions that don't have any side effects (they don't manipulate objects outside their scope). If you do so, you'll open yourself to race conditions on scale. They're guaranteed to be executed parallel on background threads.

## A little bit more

- ConcurrentMap automatically batches you work according to how many threads it's distributing the functions on. If you have 1000 elements in the array, and you execute them on 10 threads, each thread will get a 100 functions.
- The default number of threads it's using is 4. This seems to be the optimum. Feel free to play around with it, and please open an issue if you found that to be misleading.

ConcurrentMap is made available under the MIT license. 
<commit_msg>docs(readme): updated with source of inspiration<commit_after># ConcurrentMap

We all love Array.map in Swift.
Now you can speed it up by using multiple threads. Like boss.

### Why?

The question is more like, why is this not in the standard library by default :P.
ConcurrentMap is inspired [this blog post](http://blog.scottlogic.com/2014/10/29/concurrent-functional-swift.html) by [<NAME>](http://blog.scottlogic.com/ceberhardt/) 

### How?

      // specify the threads
      let newArray = array.concurrentMap({ pureFunction($0) }, threads: 2)
      
      // or just leave it, the default is 4!
      let newArray = array.concurrentMap { pureFunction($0) }
      
### Warning

Only use concurrentMap with pure functions that don't have any side effects (they don't manipulate objects outside their scope). If you do so, you'll open yourself to race conditions on scale. They're guaranteed to be executed parallel on background threads.

### A little bit more

- ConcurrentMap automatically batches you work according to how many threads it's distributing the functions on. If you have 1000 elements in the array, and you execute them on 10 threads, each thread will get a 100 functions.
- The default number of threads it's using is 4. This seems to be the optimum. Feel free to play around with it, and please open an issue if you found that to be misleading.

### License

ConcurrentMap is made available under the MIT license. 

{'fraction_non_alphanumeric': 0.06593820648078372, 'fraction_numerical': 0.013564431047475508, 'mean_word_length': 3.6825396825396823, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6042410', 'n_tokens_mistral': 724, 'n_tokens_neox': 656, 'n_words': 380}