Mercurial > lasercutter
view src/clojure/lang/StringSeq.java @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
line wrap: on
line source
1 /**2 * Copyright (c) Rich Hickey. All rights reserved.3 * The use and distribution terms for this software are covered by the4 * 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 by7 * the terms of this license.8 * You must not remove this notice, or any other, from this software.9 **/11 /* rich Dec 6, 2007 */13 package clojure.lang;15 public class StringSeq extends ASeq implements IndexedSeq{16 public final CharSequence s;17 public final int i;19 static public StringSeq create(CharSequence s){20 if(s.length() == 0)21 return null;22 return new StringSeq(null, s, 0);23 }25 StringSeq(IPersistentMap meta, CharSequence s, int i){26 super(meta);27 this.s = s;28 this.i = i;29 }31 public Obj withMeta(IPersistentMap meta){32 if(meta == meta())33 return this;34 return new StringSeq(meta, s, i);35 }37 public Object first(){38 return Character.valueOf(s.charAt(i));39 }41 public ISeq next(){42 if(i + 1 < s.length())43 return new StringSeq(_meta, s, i + 1);44 return null;45 }47 public int index(){48 return i;49 }51 public int count(){52 return s.length() - i;53 }54 }