/** * Returns the number of entries currently in this map. */ public int size() { return delegate.count(); }
public int count() { return impl.count(); }
public int count() { return impl.count(); }
public static PersistentHashMap createWithCheck(Object... init){ ITransientMap ret = EMPTY.asTransient(); for(int i = 0; i < init.length; i += 2) { ret = ret.assoc(init[i], init[i + 1]); if(ret.count() != i/2 + 1) throw new IllegalArgumentException("Duplicate key: " + init[i]); } return (PersistentHashMap) ret.persistent(); }
public static PersistentHashMap createWithCheck(Object... init){ ITransientMap ret = EMPTY.asTransient(); for(int i = 0; i < init.length; i += 2) { ret = ret.assoc(init[i], init[i + 1]); if(ret.count() != i/2 + 1) throw new IllegalArgumentException("Duplicate key: " + init[i]); } return (PersistentHashMap) ret.persistent(); }
static public PersistentHashMap createWithCheck(ISeq items){ ITransientMap ret = EMPTY.asTransient(); for(int i=0; items != null; items = items.next().next(), ++i) { if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); if(ret.count() != i + 1) throw new IllegalArgumentException("Duplicate key: " + items.first()); } return (PersistentHashMap) ret.persistent(); }
static public PersistentHashMap createWithCheck(ISeq items){ ITransientMap ret = EMPTY.asTransient(); for(int i=0; items != null; items = items.next().next(), ++i) { if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); if(ret.count() != i + 1) throw new IllegalArgumentException("Duplicate key: " + items.first()); } return (PersistentHashMap) ret.persistent(); }