make set efficient will convert all lists of items
    in levels to a set to speed up operations
352351
def make_levels_set(levels):
    ''''''
    for level_key,level_filters in levels.items():
        levels[level_key] = make_level_set(level_filters)
    return levels
656607
function setToArray$1(set) {
  var index = -1,
      result = Array(set.size);

  set.forEach(function (value) {
    result[++index] = value;
  });
  return result;
}
934798
def set_append(input_set, item):
    # type: (set, Any) -> set
    
    if item:
        if isinstance(item, (list, tuple)):
            input_set.update(item)
        else:
            input_set.add(item)
    return input_set
1275090
def _get_final_set(self, sets, pk, sort_options):
        
        conn = self.cls.get_connection()
        all_sets = set()
        tmp_keys = set()

        if pk is not None and not sets and not (sort_options and sort_options.get('get')):
            # no final set if only a pk without values to retrieve
            return (None, False)

        elif sets or pk:
            if sets:
                new_sets, new_tmp_keys = self._prepare_sets(sets)
                all_sets.update(new_sets)
                tmp_keys.update(new_tmp_keys)
            if pk is not None:
                # create a set with the pk to do intersection (and to pass it to
                # the store command to retrieve values if needed)
                tmp_key = self._unique_key()
                conn.sadd(tmp_key, pk)
                all_sets.add(tmp_key)
                tmp_keys.add(tmp_key)

        else:
            # no sets or pk, use the whole collection instead
            all_sets.add(self.cls.get_field('pk').collection_key)

        if not all_sets:
            delete_set_later = False
            final_set = None
        elif len(all_sets) == 1:
            # if we have only one set, we  delete the set after calling
            # collection only if it's a temporary one, and we do not delete
            # it right now
            final_set = all_sets.pop()
            if final_set in tmp_keys:
                delete_set_later = True
                tmp_keys.remove(final_set)
            else:
                delete_set_later = False
        else:
            # more than one set, do an intersection on all of them in a new key
            # that will must be deleted once the collection is called.
            delete_set_later = True
            final_set = self._combine_sets(all_sets, self._unique_key())

        if tmp_keys:
            conn.delete(*tmp_keys)

        # return the final set to work on, and a flag if we later need to delete it
        return (final_set, [final_set] if delete_set_later else None)
391096
def intersection(self, *iterables):
        
        comb = self._set.intersection(*iterables)
        return self._fromset(comb, key=self._key)
68246
def powerset(l):
    
    return chain.from_iterable(combinations(l, r) for r in range(len(l)+1))
283936
def sets(self):
        """"""
        sets = {}
        for x in self._parents:
            sets.setdefault(self[x], set()).add(x)
        return frozenset(frozenset(v) for v in six.viewvalues(sets))
1119828
function SortedSet(source) {
  HashMap.call(this);
  this._rtype = TYPE_NAMES.ZSET;
  if(source) {
    for(var k in source) {
      this.setKey(k, source[k]);
    }
  }
}
985485
private Set<Map.Entry<Object, ClassicCounter<K>>> lowestLevelCounterEntrySet(Set<Map.Entry<Object, ClassicCounter<K>>> s, Object[] key, boolean useLists) {
    Set<K> keys = map.keySet();
    if (depth == 2) {
      // add these counters to set
      for (K finalKey: keys) {
        K[] newKey = ErasureUtils.<K>mkTArray(Object.class,key.length + 1);
        if (key.length > 0) {
          System.arraycopy(key, 0, newKey, 0, key.length);
        }
        newKey[key.length] = finalKey;
        ClassicCounter<K> c = conditionalizeHelper(finalKey).oneDimensionalCounterView();
        if (useLists) {
          s.add(new Entry<Object,ClassicCounter<K>>(Arrays.asList(newKey), c));
        } else {
          s.add(new Entry<Object,ClassicCounter<K>>(newKey[0], c));
        }
      }
    } else {
      //System.out.println("key length " + key.length);
      //System.out.println("keyset level " + depth + " " + keys);
      for (K o: keys) {
        Object[] newKey = new Object[key.length + 1];
        if (key.length > 0) {
          System.arraycopy(key, 0, newKey, 0, key.length);
        }
        newKey[key.length] = o;
        //System.out.println("level " + key.length + " current key " + Arrays.asList(newKey));
        conditionalizeHelper(o).lowestLevelCounterEntrySet(s, newKey, true);
      }
    }
    //System.out.println("leaving key length " + key.length);
    return s;
  }
1152379
def mset(self, values):
        
        for key, value in values.items():
            self.set(key, value)
753134
function (items) {
        var self = this;

        // Force single item into array
        if (!Tools.isArray(items)) {
          if (items instanceof Collection) {
            self.add(items.toArray());
          } else {
            push.call(self, items);
          }
        } else {
          push.apply(self, items);
        }

        return self;
      }
1270290
function divideSet(set, setSize) {
  if (!setSize) {
    throw new Error(`Set Division by 0`)
  }
  let thisSet = new Set()
  let remainingItems = setSize
  const output = [thisSet]
  const iterator = set.values()
  // @ts-ignore
  for (const value of iterator) {
    if (remainingItems === 0) {
      thisSet = new Set()
      remainingItems = setSize
      output.push(thisSet)
    }
    thisSet.add(value)
    remainingItems--
  }
  return output
}
522324
private FastSet convert(IntSet c)
  {
    if (c instanceof FastSet) {
      return (FastSet) c;
    }
    if (c == null) {
      return new FastSet();
    }

    FastSet res = new FastSet();
    IntIterator itr = c.iterator();
    while (itr.hasNext()) {
      res.add(itr.next());
    }
    return res;
  }
1057057
private void convertMultipleListsToFastList()
    {
        FastList<MithraFastList<E>> localLists = this.lists;
        if (localLists.size() > 1)
        {
            final MithraFastList<E> newList = new MithraFastList<E>(this.size());

            for (int i = 0; i < localLists.size(); i++)
            {
                newList.addAll(localLists.get(i));
            }
            FastList<MithraFastList<E>> newLists = new FastList<MithraFastList<E>>(2);
            newLists.add(newList);
            this.lists = newLists;
        }
    }
1200866
public static final <T> Set<T> intersection(Collection<Set<T>> sets)
    {
        Set<T> set = union(sets);
        for (Set<T> s : sets)
        {
            set.retainAll(s);
        }
        return set;
    }
847939
private int reduceNondominatedSet(double[][] front, int noPoints, int objective,
                                    double threshold) {
    int n;
    int i;

    n = noPoints;
    for (i = 0; i < n; i++) {
      if (front[i][objective] <= threshold) {
        n--;
        swap(front, i, n);
      }
    }

    return n;
  }
630689
def mset_list(item, index, value):
    ''
    if isinstance(index, (int, slice)):
        item[index] = value
    else:
        map(item.__setitem__, index, value)