Returns the sorted set cardinality (number of elements)
of the sorted set stored at key.
162805
function zcard(key, req) {
  var zset = this.getKey(key, req);
  if(zset === undefined) return 0;
  return zset.zcard();
}
244550
def sorted_bits(self) -> List[Tuple[str, int]]:
        """"""
        return sorted(self.bit.items(), key=lambda x: x[1])
545587
private static int computeKey(Collection array) {
        int intKey = 0;
        for (Object s : array) {
            intKey += s.hashCode();
        }
        return intKey;
    }
772717
private Iterable<Key> getSplitKey(List<Key> keys, int numSplits) {
    // If the number of keys is less than the number of splits, we are limited in the number of
    // splits we can make.
    if (keys.size() < numSplits - 1) {
      return keys;
    }

    // Calculate the number of keys per split. This should be KEYS_PER_SPLIT, but may
    // be less if there are not KEYS_PER_SPLIT * (numSplits - 1) scatter entities.
    //
    // Consider the following dataset, where - represents an entity and * represents an entity
    // that is returned as a scatter entity:
    // ||---*-----*----*-----*-----*------*----*----||
    // If we want 4 splits in this data, the optimal split would look like:
    // ||---*-----*----*-----*-----*------*----*----||
    //            |          |            |
    // The scatter keys in the last region are not useful to us, so we never request them:
    // ||---*-----*----*-----*-----*------*---------||
    //            |          |            |
    // With 6 scatter keys we want to set scatter points at indexes: 1, 3, 5.
    //
    // We keep this as a double so that any "fractional" keys per split get distributed throughout
    // the splits and don't make the last split significantly larger than the rest.
    double numKeysPerSplit = Math.max(1.0, ((double) keys.size()) / (numSplits - 1));

    List<Key> keysList = new ArrayList<Key>(numSplits - 1);
    // Grab the last sample for each split, otherwise the first split will be too small.
    for (int i = 1; i < numSplits; i++) {
      int splitIndex = (int) Math.round(i * numKeysPerSplit) - 1;
      keysList.add(keys.get(splitIndex));
    }

    return keysList;
  }
796425
public long cardinality() {
        switch(type) {
            case EMPTY:
                return 0/*by definition*/;
            case EXPLICIT:
                return explicitStorage.size();
            case SPARSE:
                return (long)Math.ceil(sparseProbabilisticAlgorithmCardinality());
            case FULL:
                return (long)Math.ceil(fullProbabilisticAlgorithmCardinality());
            default:
                throw new RuntimeException("Unsupported HLL type " + type);
        }
    }
421459
def cardinality(self):
        
        data = clips.data.DataObject(self._env)

        lib.EnvSlotCardinality(
            self._env, self._cls, self._name, data.byref)

        return tuple(data.value) if isinstance(data.value, list) else ()
785021
def _get_key_index(self, row):
        """"""
        # Don't bother with empty tracks
        if len(self.keys) == 0:
            return -1

        # No track values are defined yet
        if row < self.keys[0].row:
            return -1

        # Get the insertion index
        index = bisect.bisect_left(self.keys, row)
        # Index is within the array size?
        if index < len(self.keys):
            # Are we inside an interval?
            if row < self.keys[index].row:
                return index - 1
            return index

        # Return the last index
        return len(self.keys) - 1
303450
def get_filtered_keys(self, suffix, *args, **kwargs):
        

        accepted_key_types = kwargs.get('accepted_key_types', None)

        if accepted_key_types and 'set' not in accepted_key_types:
            raise ImplementationError(
                '%s can only return keys of type "set"' % self.__class__.__name__
            )

        # special "in" case: we get n keys and make an unionstore with them then return this key
        if suffix == 'in':

            args = list(args)
            values = set(args.pop())

            if not values:
                return []  # no keys

            in_keys = [
                self.get_storage_key(transform_value=False, *(args+[value]))
                for value in values
            ]

            tmp_key = unique_key(self.connection)
            self.connection.sunionstore(tmp_key, *in_keys)

            return [(tmp_key, 'set', True)]

        # do not transform because we already have the value we want to look for
        return [(self.get_storage_key(transform_value=False, *args), 'set', False)]
41505
def natural_sorted(iterable):
    
    def sortkey(x):
        return [(int(c) if c.isdigit() else c) for c in re.split(numbers, x)]

    numbers = re.compile(r'(\d+)')
    return sorted(iterable, key=sortkey)
368850
@SuppressWarnings("unchecked")
    public Iterator<K> keys()
    {
        int size = _size;

        if (size == 0)
        {
            return null;
        }
        ArrayList<K> keyList = new ArrayList<K>();
        int i = (size - 1) * 2;
        while (i >= 0)
        {
            keyList.add((K) _array[i]);
            i = i - 2;
        }
        return keyList.iterator();
    }
233304
public int findHighestKey(int max) {
        int highest = Integer.MIN_VALUE;
        int index = index(hash(max));
        final int maxTry = capacity;
        for (int i = 0; i < maxTry; i++) {
            if (!slotIsFree(index)) {
                int k = keys[index];
                if (k == max) return max;
                if (max > k && k > highest) highest = k;
            }
            index = nextIndex(index);
        }
        return highest;
    }
1066835
def cardinality(self):
        
        cardinality = 0
        for si in self._si_set:
            cardinality += si.cardinality
        return cardinality
352177
public Cardinalities getCardinalities(Class<? extends ElementBase> sourceClass) {
        Class<?> clazz = sourceClass;
        Cardinalities cardinalities = null;
        
        while (cardinalities == null && clazz != null) {
            cardinalities = map.get(clazz);
            clazz = clazz == ElementBase.class ? null : clazz.getSuperclass();
        }
        
        return cardinalities;
    }
723738
public static <T> ImmutableSortedSet<ImmutableSortedSet<T>> immutablePowerSet(SortedSet<T> set)
    {
        return powerSet(set).collect(new Function<MutableSortedSet<T>, ImmutableSortedSet<T>>()
        {
            public ImmutableSortedSet<T> valueOf(MutableSortedSet<T> set)
            {
                return set.toImmutable();
            }
        }, TreeSortedSet.<ImmutableSortedSet<T>>newSet(Comparators.<T>powerSet())).toImmutable();
    }
300861
@Pure
	public SortedSet<Integer> toSortedSet() {
		final SortedSet<Integer> theset = new TreeSet<>();
		if (this.values != null) {
			for (int idxStart = 0; idxStart < this.values.length - 1; idxStart += 2) {
				for (int n = this.values[idxStart]; n <= this.values[idxStart + 1]; ++n) {
					theset.add(n);
				}
			}
		}
		return theset;
	}
297346
def order_by(self, key):
        
        if key is None:
            raise NullArgumentError(u"No key for sorting given")
        kf = [OrderingDirection(key, reverse=False)]
        return SortedEnumerable3(kf, self._data)
123019
public static <T> int binarySearch(List<? extends Comparable<? super T>> sortedList, T key) {
		return Collections.binarySearch(sortedList, key);
	}