| 14 | import java.util.*; |
| 15 | |
| 16 | public class PersistentList extends ASeq implements IPersistentList, IReduce, List, Counted { |
| 17 | |
| 18 | private static final long serialVersionUID = -8833289659955219995L; |
| 19 | |
| 20 | private final Object _first; |
| 21 | private final IPersistentList _rest; |
| 22 | private final int _count; |
| 23 | |
| 24 | static public class Primordial extends RestFn{ |
| 25 | final public int getRequiredArity(){ |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | final protected Object doInvoke(Object args) { |
| 30 | if(args instanceof ArraySeq) |
| 31 | { |
| 32 | Object[] argsarray = ((ArraySeq) args).array; |
| 33 | IPersistentList ret = EMPTY; |
| 34 | for(int i = argsarray.length - 1; i >= ((ArraySeq)args).i; --i) |
| 35 | ret = (IPersistentList) ret.cons(argsarray[i]); |
| 36 | return ret; |
| 37 | } |
| 38 | LinkedList list = new LinkedList(); |
| 39 | for(ISeq s = RT.seq(args); s != null; s = s.next()) |
| 40 | list.add(s.first()); |
| 41 | return create(list); |
| 42 | } |
| 43 | |
| 44 | static public Object invokeStatic(ISeq args) { |
| 45 | if(args instanceof ArraySeq) |
| 46 | { |
| 47 | Object[] argsarray = ((ArraySeq) args).array; |
| 48 | IPersistentList ret = EMPTY; |
| 49 | for(int i = argsarray.length - 1; i >= 0; --i) |
| 50 | ret = (IPersistentList) ret.cons(argsarray[i]); |
| 51 | return ret; |
| 52 | } |
| 53 | LinkedList list = new LinkedList(); |
| 54 | for(ISeq s = RT.seq(args); s != null; s = s.next()) |
| 55 | list.add(s.first()); |
| 56 | return create(list); |
| 57 | } |
| 58 | |
| 59 | public IObj withMeta(IPersistentMap meta){ |
| 60 | throw new UnsupportedOperationException(); |
| 61 | } |
| 62 | |
| 63 | public IPersistentMap meta(){ |
| 64 | return null; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | public static IFn creator = new Primordial(); |
| 69 | |
| 70 | final public static EmptyList EMPTY = new EmptyList(null); |
| 71 | |
| 72 | public PersistentList(Object first){ |
| 73 | this._first = first; |
nothing calls this directly
no outgoing calls
no test coverage detected