Return random element(s) from the set value stored at key.
16739
function srandmember(key /* count, req */) {
  var args = slice.call(arguments, 1)
    , req = typeof args[args.length-1] === 'object' ? args.pop() : null
    , val = this.getKey(key, req);
  if(val === undefined) {
    return args[0] === undefined ? null : [];
  }
  return val.srandmember(args[0]);
}
1196451
def _get_set(self, key, operation, create=False):
        
        return self._get_by_type(key, operation, create, b'set', set())
252687
def randval(self):
        """"""
        fmtt = self.fmt[-1]
        if fmtt in "BHIQ":
            return {"B":RandByte,"H":RandShort,"I":RandInt, "Q":RandLong}[fmtt]()
        elif fmtt == "s":
            if self.fmt[0] in "0123456789":
                l = int(self.fmt[:-1])
            else:
                l = int(self.fmt[1:-1])
            return RandBin(l)
        else:
            warning("no random class for [%s] (fmt=%s)." % (self.name, self.fmt))
325073
def union(self, key, *others):
        """"""
        if not isinstance(key, str):
            raise ValueError("String expected.")
        self.db.sunionstore(key, [self.key] + [o.key for o in others])
        return Set(key)
582133
def getset(self, key, value, *, encoding=_NOTSET):
        """"""
        return self.execute(b'GETSET', key, value, encoding=encoding)
976598
def randset(self):
        
        return {
            self._map_type(int)
            for x in range(self.random.randint(3, 10))}
484676
def intersection(self, key, *others):
        """"""
        if not isinstance(key, str):
            raise ValueError("String expected.")
        self.db.sinterstore(key, [self.key] + [o.key for o in others])
        return Set(key)
605100
def _get_by(key, val, l):
    
    return [x for x in l if _check_value_recursively(key, val, x)]
1286848
def _getitem(self, key):
		""""""
		loc = self._bisect_right(key) - 1
		value = self._values[loc]
		if value is NOT_SET:
			raise KeyError(key)
		else:
			return value
287417
private static int[] mapRandomKeys(String randomKeys, boolean control, boolean meta) {
        if(randomKeys == null)
            throw null;

        //parse the rest after control/meta
        int[] out;
        int pos = 0;
        if(meta) {
            out = new int[randomKeys.length()+1];
            out[0] = 27;
            pos = 1;
        }
        else
            out = new int[randomKeys.length()];

        int[] random;
        if(control)
            random = convertRandomControlKeys(randomKeys);
        else
            random = convertRandomKeys(randomKeys);

        for(int i=0; i < random.length; i++,pos++)
            out[pos] = random[i];

        return out;
    }
537855
def generator(self, random, args):
        """"""
        if self.duplicates:
            max_count = [self.capacity // item[0] for item in self.items]
            return [random.randint(0, m) for m in max_count]
        else:
            return [random.choice([0, 1]) for _ in range(len(self.items))]
35479
def rand(self, count=1):
        
        result = self._client.srandmember(self.key_prefix, count)
        return set(map(self._loads, result))
132414
def from_keyed_iterable(iterable, key, filter_func=None):
    """"""

    generated = {}

    for element in iterable:
        try:
            k = getattr(element, key)
        except AttributeError:
            raise RuntimeError("{} does not have the keyed attribute: {}".format(
                element, key
            ))

        if filter_func is None or filter_func(element):
            if k in generated:
                generated[k] += [element]
            else:
                generated[k] = [element]

    return generated
954824
function random(arr) {

  if(!arr) { return false; }

  if(!arr.length) {
    arr = Object.keys(arr);
  }
  return arr[Math.floor(Math.random() * arr.length)];
}
1368368
private int randomValue(IntVar x) {
        int i = rnd.nextInt(x.getDomainSize());
        DisposableValueIterator ite = x.getValueIterator(true);
        int pos = -1;
        try {
            while (i >= 0) {
                pos = ite.next();
                i--;
            }
        } finally {
            ite.dispose();
        }
        return pos;
    }
951557
public static <T> /* @Nullable */ T random(final @NonNull Random random, final @NonNull Iterable<T> iterable) {
    final int size = Iterables.size(iterable);
    if(size == 0) {
      throw new IndexOutOfBoundsException("cannot get random value from empty iterable");
    }
    final int index = random.nextInt(size);
    return Iterables.get(iterable, index);
  }
372545
def get_random_id(length):
    """"""
    alphabet = string.ascii_uppercase + string.ascii_lowercase + string.digits
    return ''.join(random.choice(alphabet) for _ in range(length))