Пример #1
0
 public static PersistentHashSet create(ISeq items) {
   PersistentHashSet ret = EMPTY;
   for (; items != null; items = items.next()) {
     ret = (PersistentHashSet) ret.cons(items.first());
   }
   return ret;
 }
Пример #2
0
 public static PersistentHashSet create(List init) {
   PersistentHashSet ret = EMPTY;
   for (Object key : init) {
     ret = (PersistentHashSet) ret.cons(key);
   }
   return ret;
 }
Пример #3
0
 public static PersistentHashSet create(Object... init) {
   PersistentHashSet ret = EMPTY;
   for (int i = 0; i < init.length; i++) {
     ret = (PersistentHashSet) ret.cons(init[i]);
   }
   return ret;
 }
Пример #4
0
 public static PersistentHashSet createWithCheck(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 IllegalArgumentException("Duplicate key: " + init[i]);
   }
   return ret;
 }
Пример #5
0
 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 IllegalArgumentException("Duplicate key: " + items.first());
   }
   return ret;
 }
Пример #6
0
 public static PersistentHashSet createWithCheck(List init) {
   PersistentHashSet ret = EMPTY;
   int i = 0;
   for (Object key : init) {
     ret = (PersistentHashSet) ret.cons(key);
     if (ret.count() != i + 1) throw new IllegalArgumentException("Duplicate key: " + key);
     ++i;
   }
   return ret;
 }
Пример #7
0
 public IPersistentCollection empty() {
   return EMPTY.withMeta(meta());
 }