Returns a StorableIndex which is unique, possibly by appending
properties from the given key. If index is already unique, it is
returned as-is.
326323
public StorableIndex<S> uniquify(StorableKey<S> key) {
        if (key == null) {
            throw new IllegalArgumentException();
        }

        if (isUnique()) {
            return this;
        }

        StorableIndex<S> index = this;

        for (OrderedProperty<S> keyProp : key.getProperties()) {
            index = index.addProperty
                (keyProp.getChainedProperty().getPrimeProperty(), keyProp.getDirection());
        }

        return index.unique(true);
    }
1085630
def _convert_key(self, key, is_setter=False):
        
        for a, i in zip(self.obj.axes, key):
            if not is_integer(i):
                raise ValueError("iAt based indexing can only have integer "
                                 "indexers")
        return key
429594
public int indexOfKey(Object key) {
        return key == null ? indexOfNull() : indexOf(key, key.hashCode());
    }
846659
def distinct(self, fieldname, key=None):
        
        return tuple(unique_everseen(self[fieldname], key=key))
416812
def ensure_index(self, key, sparse=False):
        
        self.create_index(key, reindex=False, sparse=False)
707150
def uniqueify(x:Series, sort:bool=False)->List:
    ""
    res = list(OrderedDict.fromkeys(x).keys())
    if sort: res.sort()
    return res
670775
def is_unique(keys, *, scope=None, comparison_operators=None, present_optional=False,
                message=None):
    
    def check(pname, validator):
      """Checks that a value is unique in its column, with an optional scope."""
      # pylint: disable=too-many-branches
      model = validator.model
      data_access = validator.data_access
      pkname = model.primary_key_name
      pkey = model.primary_key

      if isinstance(keys, str):
        key = getattr(model, keys)

        if present_optional and key is None:
          return True

        if comparison_operators:
          if isinstance(comparison_operators, str):
            op = comparison_operators
          else:
            op = comparison_operators[0]
        else:
          op = " = "

        constraints = [(keys, key, op)]
      else:
        if comparison_operators:
          ops = comparison_operators
        else:
          ops = [" = "] * len(keys)

        constraints = list(zip(keys, [getattr(model, key) for key in keys], ops))

      if scope:
        if comparison_operators:
          ops = comparison_operators[len(constraints):]
        else:
          ops = [" = "] * len(scope)

        constraints.extend(zip(scope, [getattr(model, col) for col in scope], ops))

      dupe = data_access.find(model.table_name, constraints, columns=pkname)

      if dupe is None:
        return True
      if isinstance(pkname, str):
        return dupe[0] == pkey
      else:
        return tuple(dupe) == tuple(pkey)

    return Validation(check, keys, message or "is already taken", is_simple=False)
177034
def all_unique(keys, axis=semantics.axis_default):
    """"""
    index = as_index(keys, axis)
    return index.groups == index.size
790695
def unique(iterable):
    
    """
    d = {}
    return (d.setdefault(x,x) for x in iterable if x not in d)
1302937
function(obj) {
    var key = JSON.stringify(obj);
    if (!(key in this.map)) {
      this.map[key] = this.unique.length;
      this.unique.push(obj);
    }
    return this.map[key];
  }
10093
def add(self, *args, **kwargs):
        

        check_uniqueness = kwargs.get('check_uniqueness', True)

        key = self.get_storage_key(*args)
        if self.field.unique and check_uniqueness:
            self.check_uniqueness(key=key, *args)

        # Do index => create a key to be able to retrieve parent pk with
        # current field value]
        pk = self.instance.pk.get()
        logger.debug("adding %s to index %s" % (pk, key))
        self.connection.sadd(key, pk)
        self._indexed_values.add(tuple(args))
919919
def unique_justseen(iterable, key=None):
    
    return map(next, map(operator.itemgetter(1), groupby(iterable, key)))
1077005
def convert_key_to_index(keys, key):
    '''
    
    '''
    index = _key_to_index(keys, key)
    single = isinstance(index, int)
    return index, single
8390
def index(self, key):
        
        if is_iterable(key):
            return [self.index(subkey) for subkey in key]
        return self.map[key]
1316689
private int indexOf(int key) {
		int startIndex = hashIndex(key);
		int index = startIndex;

		for (;;) {
			if (values[index] == null) {
				// It's available, so no chance that this value exists anywhere in the map.
				return -1;
			}
			if (key == keys[index]) {
				return index;
			}

			// Conflict, keep probing ...
			if ((index = probeNext(index)) == startIndex) {
				return -1;
			}
		}
	}
1184763
def uniquekeys(self, metakey=None):
        
        if metakey is None:
            return self._uniquekeys
        else:
            if metakey not in self.metakeys():
                raise ValueError('metakey %s does not exist' % metakey)
            return self._uniquekeys[metakey]
1029025
def check_index(self, key, *, index):
        
        self.append({
            "Verb": "check-index",
            "Key": key,
            "Index": extract_attr(index, keys=["ModifyIndex", "Index"])
        })
        return self