public boolean equals(Object obj) { if (!(obj instanceof Sequential)) return false; ISeq ms = RT.seq(obj); for (ISeq s = seq(); s != null; s = s.next(), ms = ms.next()) { if (ms == null || !Util.equals(s.first(), ms.first())) return false; } return ms == null; }
public PersistentQueue pop() { if (f == null) // hmmm... pop of empty queue -> empty queue? return this; // throw new IllegalStateException("popping empty queue"); ISeq f1 = f.next(); PersistentVector r1 = r; if (f1 == null) { f1 = RT.seq(r); r1 = null; } return new PersistentQueue(meta(), cnt - 1, f1, r1); }
public final synchronized ISeq seq() { sval(); if (sv != null) { Object ls = sv; sv = null; while (ls instanceof LazySeq) { ls = ((LazySeq) ls).sval(); } s = RT.seq(ls); } return s; }
public IPersistentCollection cons(Object o) { if (o instanceof Map.Entry) { Map.Entry e = (Map.Entry) o; return assoc(e.getKey(), e.getValue()); } else if (o instanceof IPersistentVector) { IPersistentVector v = (IPersistentVector) o; if (v.count() != 2) throw new IllegalArgumentException("Vector arg to map conj must be a pair"); return assoc(v.nth(0), v.nth(1)); } IPersistentMap ret = this; for (ISeq es = RT.seq(o); es != null; es = es.next()) { Map.Entry e = (Map.Entry) es.first(); ret = ret.assoc(e.getKey(), e.getValue()); } return ret; }
public ISeq seq() { if (f == null) return null; return new Seq(f, RT.seq(r)); }
public boolean equals(Object o) { ISeq s = seq(); if (s != null) return s.equiv(o); else return (o instanceof Sequential || o instanceof List) && RT.seq(o) == null; }