Mercurial > lasercutter
comparison src/clojure/lang/LazilyPersistentVector.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 14, 2008 */ | |
12 | |
13 package clojure.lang; | |
14 | |
15 import java.util.Collection; | |
16 | |
17 public class LazilyPersistentVector{ | |
18 | |
19 | |
20 static public IPersistentVector createOwning(Object... items){ | |
21 if(items.length == 0) | |
22 return PersistentVector.EMPTY; | |
23 else if(items.length <= 32) | |
24 return new PersistentVector(items.length, 5, PersistentVector.EMPTY_NODE,items); | |
25 return PersistentVector.create(items); | |
26 } | |
27 | |
28 static public IPersistentVector create(Collection coll){ | |
29 if(!(coll instanceof ISeq) && coll.size() <= 32) | |
30 return createOwning(coll.toArray()); | |
31 return PersistentVector.create(RT.seq(coll)); | |
32 } | |
33 | |
34 } |