public ISeq seq() { return getMap().seq(); }
public ISeq seq() { return getMap().seq(); }
public ISeq next(){ if(i + 1 < vals.length) return new Seq(_meta, keys.next(), vals, i + 1, ext); return ext.seq(); } }
static public KeySeq createFromMap(IPersistentMap map){ if(map == null) return null; ISeq seq = map.seq(); if(seq == null) return null; return new KeySeq(seq, map); }
static public ValSeq createFromMap(IPersistentMap map) { if(map == null) return null; ISeq seq = map.seq(); if(seq == null) return null; return new ValSeq(seq, map); }
public ISeq seq() { return getMap().seq(); }
public ISeq seq() { return getMap().seq(); }
public ISeq seq() { return getMap().seq(); }
static public int mapHash(IPersistentMap m){ int hash = 0; for(ISeq s = m.seq(); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); hash += (e.getKey() == null ? 0 : e.getKey().hashCode()) ^ (e.getValue() == null ? 0 : e.getValue().hashCode()); } return hash; }
static public int mapHash(IPersistentMap m){ int hash = 0; for(ISeq s = m.seq(); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); hash += (e.getKey() == null ? 0 : e.getKey().hashCode()) ^ (e.getValue() == null ? 0 : e.getValue().hashCode()); } return hash; }
static public boolean mapEquals(IPersistentMap m1, Object obj){ if(m1 == obj) return true; if(!(obj instanceof Map)) return false; Map m = (Map) obj; if(m.size() != m1.count()) return false; for(ISeq s = m1.seq(); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); boolean found = m.containsKey(e.getKey()); if(!found || !Util.equals(e.getValue(), m.get(e.getKey()))) return false; } return true; }
public ISeq next(){ if(i + 1 < vals.length) return new Seq(_meta, keys.next(), vals, i + 1, ext); return ext.seq(); } }
static public boolean mapEquals(IPersistentMap m1, Object obj){ if(m1 == obj) return true; if(!(obj instanceof Map)) return false; Map m = (Map) obj; if(m.size() != m1.count()) return false; for(ISeq s = m1.seq(); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); boolean found = m.containsKey(e.getKey()); if(!found || !Util.equals(e.getValue(), m.get(e.getKey()))) return false; } return true; }
public void notifyWatches(Object oldval, Object newval){ IPersistentMap ws = watches; if(ws.count() > 0) { for(ISeq s = ws.seq(); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); IFn fn = (IFn) e.getValue(); if(fn != null) fn.invoke(e.getKey(), this, oldval, newval); } } } }
public void notifyWatches(Object oldval, Object newval){ IPersistentMap ws = watches; if(ws.count() > 0) { for(ISeq s = ws.seq(); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); IFn fn = (IFn) e.getValue(); try { if(fn != null) fn.invoke(e.getKey(), this, oldval, newval); } catch(Exception e1) { throw Util.sneakyThrow(e1); } } } } }
@Override public EvalResult interpret(Environment d, IPersistentMap bindings) { if (compiled!=null) return d.withResult(compiled); // TODO is this sensible? capture the dynamic environment at exact point of lambda creation? Environment e=d; for (ISeq s= bindings.seq(); s!=null; s=s.next()) { Entry<?, ?> me=(Entry<?, ?>)s.first(); e=e.assoc(me.getKey(),me.getValue()); } KFn fn=LambdaFn.create(e,body,syms); return d.withResult(fn); }