Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

clojure.core/seque takes an optional argument that can be the initial capacity for a LinkedBlockingQueue or an instance of the BlockingQueue interface.

PriorityBlockingQueue is such a class, but fails to work because seque makes a few assumptions about BlockingQueues that are not true for all BlockingQueues.

user=> (def s (seque (java.util.concurrent.PriorityBlockingQueue. 100) (shuffle (range 100))))

'user/s

user=> s
java.lang.NullPointerException

user=> (seque (java.util.concurrent.SynchronousQueue.) (shuffle (range 100)))

user=> (seque (java.util.concurrent.ArrayBlockingQueue. 10) (shuffle (range 100)))
(39 41 27 76 1 24 92 34 72 37 67 99 38 21 5 64 9 26 59 43 82 65 3 11 31 93 50 63 15 90 13 75 40 97 57 88 86 53 19 83 2 12 54 49 71 28 68 73 96 44 8 98 61 6 22 25 78 66 32 84 60 94 70 7 89 4 33 55 74 81 51 56 62 87 69 80 77 20 30 91 52 10 48 18 36 58 47 14 16 42 35 17 95 0 45 85 29 23 46 79)

3 Answers

0 votes
by

Comment made by: pepijndevos

A working implementation with some tests.

0 votes
by

Comment made by: pepijndevos

Attachement removed, I'm working on it here: https://gist.github.com/934781

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-776 (reported by pepijndevos)
...