MCPcopy Index your code
hub / github.com/clojure/clojure / Range

Class Range

src/jvm/clojure/lang/Range.java:19–219  ·  view source on GitHub ↗

Implements generic numeric (potentially infinite) range.

Source from the content-addressed store, hash-verified

17 * Implements generic numeric (potentially infinite) range.
18 */
19public class Range extends ASeq implements IChunkedSeq, IReduce {
20
21private static final long serialVersionUID = -71973733672395145L;
22
23private static final int CHUNK_SIZE = 32;
24
25// Invariants guarantee this is never an "empty" seq
26// assert(start != end && step != 0)
27final Object end;
28final Object start;
29final Object step;
30final BoundsCheck boundsCheck;
31private volatile IChunk _chunk; // lazy
32private volatile ISeq _chunkNext; // lazy
33private volatile ISeq _next; // cached
34
35private static interface BoundsCheck extends Serializable {
36 boolean exceededBounds(Object val);
37}
38
39private static BoundsCheck positiveStep(final Object end) {
40 return new BoundsCheck() {
41 public boolean exceededBounds(Object val){
42 return Numbers.gte(val, end);
43 }
44 };
45}
46
47private static BoundsCheck negativeStep(final Object end) {
48 return new BoundsCheck() {
49 public boolean exceededBounds(Object val){
50 return Numbers.lte(val, end);
51 }
52 };
53}
54
55private Range(Object start, Object end, Object step, BoundsCheck boundsCheck){
56 this.end = end;
57 this.start = start;
58 this.step = step;
59 this.boundsCheck = boundsCheck;
60}
61
62private Range(Object start, Object end, Object step, BoundsCheck boundsCheck, IChunk chunk, ISeq chunkNext){
63 this.end = end;
64 this.start = start;
65 this.step = step;
66 this.boundsCheck = boundsCheck;
67 this._chunk = chunk;
68 this._chunkNext = chunkNext;
69}
70
71private Range(IPersistentMap meta, Object start, Object end, Object step, BoundsCheck boundsCheck, IChunk chunk, ISeq chunkNext){
72 super(meta);
73 this.end = end;
74 this.start = start;
75 this.step = step;
76 this.boundsCheck = boundsCheck;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected