public static PersistentHashSet createWithCheck(ISeq items) { PersistentHashSet ret = EMPTY; for (int i = 0; items != null; items = items.next(), ++i) { ret = (PersistentHashSet)ret.cons(items.first()); if (ret.count() != i + 1) { throw new ArgumentException("Duplicate key: " + items.first()); } } return(ret); }
public static PersistentHashSet createWithCheck(params object[] init) { PersistentHashSet ret = EMPTY; for (int i = 0; i < init.Length; i++) { ret = (PersistentHashSet)ret.cons(init[i]); if (ret.count() != i + 1) { throw new ArgumentException("Duplicate key: " + init[i]); } } return(ret); }
public static PersistentHashSet createWithCheck(IList init) { PersistentHashSet ret = EMPTY; int i = 0; foreach (Object key in init) { ret = (PersistentHashSet)ret.cons(key); if (ret.count() != i + 1) { throw new ArgumentException("Duplicate key: " + key); } ++i; } return(ret); }