Skip to content

Commit 3ff5b94

Browse files
committed
[lazy] added Seqable
1 parent e9a4292 commit 3ff5b94

File tree

6 files changed

+28
-13
lines changed

6 files changed

+28
-13
lines changed

src/jvm/clojure/lang/APersistentVector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static boolean doEquals(IPersistentVector v, Object obj){
7272
{
7373
if(!(obj instanceof Sequential))
7474
return false;
75-
ISeq ms = ((IPersistentCollection) obj).seq();
75+
ISeq ms = RT.seq(obj);
7676
for(int i = 0; i < v.count(); i++, ms = ms.rest())
7777
{
7878
if(ms == null || !Util.equals(v.nth(i), ms.first()))
@@ -115,7 +115,7 @@ static boolean doEquiv(IPersistentVector v, Object obj){
115115
{
116116
if(!(obj instanceof Sequential))
117117
return false;
118-
ISeq ms = ((IPersistentCollection) obj).seq();
118+
ISeq ms = RT.seq(obj);
119119
for(int i = 0; i < v.count(); i++, ms = ms.rest())
120120
{
121121
if(ms == null || !Util.equiv(v.nth(i), ms.first()))

src/jvm/clojure/lang/IPersistentCollection.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
*/
1212

1313

14-
public interface IPersistentCollection {
14+
public interface IPersistentCollection extends Seqable {
1515

1616
int count();
1717

18-
ISeq seq();
19-
2018
IPersistentCollection cons(Object o);
2119

2220
IPersistentCollection empty();

src/jvm/clojure/lang/ISeq.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package clojure.lang;
2-
31
/**
42
* Copyright (c) Rich Hickey. All rights reserved.
53
* The use and distribution terms for this software are covered by the
@@ -10,6 +8,8 @@
108
* You must not remove this notice, or any other, from this software.
119
*/
1210

11+
package clojure.lang;
12+
1313
/**
1414
* A persistent, functional, sequence interface
1515
* <p/>

src/jvm/clojure/lang/PersistentQueue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public boolean equiv(Object obj){
4141

4242
if(!(obj instanceof Sequential))
4343
return false;
44-
ISeq ms = ((IPersistentCollection) obj).seq();
44+
ISeq ms = RT.seq(obj);
4545
for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
4646
{
4747
if(ms == null || !Util.equiv(s.first(), ms.first()))
@@ -55,7 +55,7 @@ public boolean equals(Object obj){
5555

5656
if(!(obj instanceof Sequential))
5757
return false;
58-
ISeq ms = ((IPersistentCollection) obj).seq();
58+
ISeq ms = RT.seq(obj);
5959
for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
6060
{
6161
if(ms == null || !Util.equals(s.first(), ms.first()))

src/jvm/clojure/lang/RT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ static public ISeq seq(Object coll){
447447
return null;
448448
else if(coll instanceof ISeq)
449449
return (ISeq) coll;
450-
else if(coll instanceof IPersistentCollection)
451-
return ((IPersistentCollection) coll).seq();
450+
else if(coll instanceof Seqable)
451+
return ((Seqable) coll).seq();
452452
else
453453
return seqFrom(coll);
454454
}
@@ -722,7 +722,7 @@ else if(n == 1)
722722

723723
else if(coll instanceof Sequential)
724724
{
725-
ISeq seq = ((IPersistentCollection) coll).seq();
725+
ISeq seq = RT.seq(coll);
726726
coll = null;
727727
for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest())
728728
{
@@ -785,7 +785,7 @@ else if(n == 1)
785785
}
786786
else if(coll instanceof Sequential)
787787
{
788-
ISeq seq = ((IPersistentCollection) coll).seq();
788+
ISeq seq = RT.seq(coll);
789789
coll = null;
790790
for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest())
791791
{

src/jvm/clojure/lang/Seqable.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 Jan 28, 2009 */
12+
13+
package clojure.lang;
14+
15+
public interface Seqable {
16+
ISeq seq();
17+
}

0 commit comments

Comments
 (0)