-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
113 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
name: "Push CI - master" | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
branches: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(ns aerospike-clj.collections | ||
(:import (java.util ArrayList Collection Collections List) | ||
(java.util.function Consumer))) | ||
|
||
(defn ->list | ||
"Returns a new [[java.util.List]] containing the result of applying `mapper-fn` to each item in `col`. | ||
Returns an unmodifiable list. | ||
*Note*: This will usually be faster than `(mapv mapper-fn col)` because: | ||
- This function allocates a new [[java.util.ArrayList]] in the exact `(.size col)` size, and then | ||
fills it with the mapped values. | ||
- If the underlying collection is not a Clojure sequence, then `mapv` will first convert it | ||
to a Clojure sequence and then map over it. This function will not do that." | ||
^List [mapper-fn ^Collection col] | ||
(let [res (ArrayList. (.size col))] | ||
(.forEach col | ||
(reify Consumer | ||
(accept [_ item] | ||
(.add res (mapper-fn item))))) | ||
(Collections/unmodifiableList res))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters