Mercurial > lasercutter
comparison src/clojure/lang/ChunkedCons.java @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:35cf337adfcf | 10:ef7dbbd6452c |
---|---|
1 /** | |
2 * Copyright (c) Rich Hickey. All rights reserved. | |
3 * The use and distribution terms for this software are covered by the | |
4 * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | |
5 * which can be found in the file epl-v10.html at the root of this distribution. | |
6 * By using this software in any fashion, you are agreeing to be bound by | |
7 * the terms of this license. | |
8 * You must not remove this notice, or any other, from this software. | |
9 **/ | |
10 | |
11 /* rich May 25, 2009 */ | |
12 | |
13 package clojure.lang; | |
14 | |
15 final public class ChunkedCons extends ASeq implements IChunkedSeq{ | |
16 | |
17 final IChunk chunk; | |
18 final ISeq _more; | |
19 | |
20 ChunkedCons(IPersistentMap meta, IChunk chunk, ISeq more){ | |
21 super(meta); | |
22 this.chunk = chunk; | |
23 this._more = more; | |
24 } | |
25 | |
26 public ChunkedCons(IChunk chunk, ISeq more){ | |
27 this(null,chunk, more); | |
28 } | |
29 | |
30 public Obj withMeta(IPersistentMap meta){ | |
31 if(meta != _meta) | |
32 return new ChunkedCons(meta, chunk, _more); | |
33 return this; | |
34 } | |
35 | |
36 public Object first(){ | |
37 return chunk.nth(0); | |
38 } | |
39 | |
40 public ISeq next(){ | |
41 if(chunk.count() > 1) | |
42 return new ChunkedCons(chunk.dropFirst(), _more); | |
43 return chunkedNext(); | |
44 } | |
45 | |
46 public ISeq more(){ | |
47 if(chunk.count() > 1) | |
48 return new ChunkedCons(chunk.dropFirst(), _more); | |
49 if(_more == null) | |
50 return PersistentList.EMPTY; | |
51 return _more; | |
52 } | |
53 | |
54 public IChunk chunkedFirst(){ | |
55 return chunk; | |
56 } | |
57 | |
58 public ISeq chunkedNext(){ | |
59 return chunkedMore().seq(); | |
60 } | |
61 | |
62 public ISeq chunkedMore(){ | |
63 if(_more == null) | |
64 return PersistentList.EMPTY; | |
65 return _more; | |
66 } | |
67 } |