Validates that all items in the given field list value are distinct,
    i.e. that the list contains no duplicates.
336435
def distinct():
    
    def validate(value):
        for i, item in enumerate(value):
            if item in value[i+1:]:
                return e("{} is not a distinct set of values", value)
    return validate
732081
def check_uniqueness(self, *args, **kwargs):
        

        if not self.field.unique:
            return

        try:
            pk = self.instance.pk.get()
        except AttributeError:
            pk = None

        key = self.get_storage_key(*args)
        value = list(args)[-1]
        pks = self.get_pks_for_filter(key, 'eq', self.normalize_value(value))

        self.assert_pks_uniqueness(pks, pk, value)
672982
def _check_unique_together(cls):
        """"""
        if cls._meta.unique_together is None:
            return

        if not isinstance(cls._meta.unique_together, (tuple, list)):
            raise ConfigurationError(
                "'{}.unique_together' must be a list or tuple.".format(cls.__name__)
            )

        elif any(
            not isinstance(unique_fields, (tuple, list))
            for unique_fields in cls._meta.unique_together
        ):
            raise ConfigurationError(
                "All '{}.unique_together' elements must be lists or tuples.".format(cls.__name__)
            )

        else:
            for fields_tuple in cls._meta.unique_together:
                for field_name in fields_tuple:
                    field = cls._meta.fields_map.get(field_name)

                    if not field:
                        raise ConfigurationError(
                            "'{}.unique_together' has no '{}' "
                            "field.".format(cls.__name__, field_name)
                        )

                    if isinstance(field, ManyToManyField):
                        raise ConfigurationError(
                            "'{}.unique_together' '{}' field refers "
                            "to ManyToMany field.".format(cls.__name__, field_name)
                        )
1326606
def unique_list(input_list):
    
    """
    output_list = []
    if len(input_list) > 0:
        dim = _sp.shape(input_list)[1]
        for i in input_list:
            match = False
            for j in output_list:
                if dim == 3:
                    if i[0] == j[0] and i[1] == j[1] and i[2] == j[2]:
                        match = True
                elif dim == 2:
                    if i[0] == j[0] and i[1] == j[1]:
                        match = True
                elif dim == 1:
                    if i[0] == j[0]:
                        match = True
            if match is False:
                output_list.append(i)
    return output_list
164425
def check_unique(self):
        """"""
        errors = []
        service_id = getattr(self, 'id', None)
        fields = [('location', views.service_location),
                  ('name', views.service_name)]

        for field, view in fields:
            value = getattr(self, field, None)
            if not value:
                continue

            result = yield view.values(key=value)
            matched = {x['id'] for x in result if x['id'] != service_id}
            if matched:
                errors.append("Service with {} '{}' already exists"
                              .format(field, value))

        if errors:
            raise exceptions.ValidationError(errors)
917321
def fast_distinct(self):
        
        return self.model.objects.filter(pk__in=self.values_list('pk', flat=True))
1052838
function distinct(array){
  return Object.keys(array.reduce(function(current, value){
    current[value] = true;
    return current;
  }, {}));
}
865880
function isInList(value, listOfValues, msg) {
    value = value.toLowerCase().trim();
    if (listOfValues.indexOf(value) === -1) {
        throw new Error(msg);
    }
}
25501
def ensure_unique(qs, field_name, value, exclude_id=None):
    
    orig = value
    if not value:
        value = "None"
    for x in itertools.count(1):
        if not qs.exclude(id=exclude_id).filter(**{field_name: value}).exists():
            break
        if orig:
            value = '%s-%d' % (orig, x)
        else:
            value = '%d' % x

    return value
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)
804725
def is_unique(seq):
    ''''''
    try:
        s = set(seq)
        return len(s) == len(seq)
    except TypeError:
        buf = []
        for item in seq:
            if item in buf:
                return False
            buf.append(item)
        return True
83709
def valid(self, value, level=[]):
		

		# Reset validation failures
		self.validation_failures = []

		# If the value is None and it's optional, we're good
		if value is None and self._optional:
			return True

		# If the value isn't a list
		if not isinstance(value, list):
			self.validation_failures.append(('.'.join(level), str(value)))
			return False

		# Init the return, assume valid
		bRet = True

		# Keep track of duplicates
		if self._type == 'unique':
			lItems	= []

		# Go through each item in the list
		for i in range(len(value)):

			# Add the field to the level
			lLevel = level[:]
			lLevel.append('[%d]' % i)

			# If the element isn't valid, return false
			if not self._node.valid(value[i], lLevel):
				self.validation_failures.extend(self._node.validation_failures[:])
				bRet = False;
				continue;

			# If we need to check for duplicates
			if self._type == 'unique':

				# Try to get an existing item
				try:

					# If it is found, we have a duplicate
					iIndex = lItems.index(value[i])

					# Add the error to the list
					self.validation_failures.append(('.'.join(lLevel), 'duplicate of %s[%d]' % ('.'.join(level), iIndex)))
					bRet = False
					continue

				# If a Value Error is thrown, there is no duplicate, add the
				# 	value to the list and continue
				except ValueError:
					lItems.append(value[i])

		# If there's a minumum
		if self._minimum is not None:

			# If we don't have enough
			if len(value) < self._minimum:
				self.validation_failures.append(('.'.join(level), 'did not meet minimum'))
				bRet = False

		# If there's a maximum
		if self._maximum is not None:

			# If we have too many
			if len(value) > self._maximum:
				self.validation_failures.append(('.'.join(level), 'exceeds maximum'))
				bRet = False

		# Return whatever the result was
		return bRet
883316
private static boolean shouldHasUniqueValues(List<Field> dataFields) {
        Set<String> dataValues = new HashSet<>();
        for (Field field : dataFields) {
            String value = field.getAnnotation(Plugin.Data.class).value();
            if (dataValues.contains(value)) {
                return false;
            }
            dataValues.add(value);
        }
        return true;
    }
707390
def remove_duplicates_from_list(array):
    ""
    output = []
    unique = set()
    for a in array:
        if a not in unique:
            unique.add(a)
            output.append(a)
    return output
1109424
def _val_is_unique(val, field):
        
        if val is None:
            return False

        if not field.unique:
            return True

        field_name = field.name
        return field.model.objects.filter(**{field_name: val}).count() == 0
12185
private static void validateNewAddition(Vector paths, ExpressionOwner owner, 
                                          LocPathIterator path) 
		throws RuntimeException 
  {
  	assertion(owner.getExpression() == path, "owner.getExpression() != path!!!");
	int n = paths.size();
	// There should never be any duplicates in the list!
	for(int i = 0; i < n; i++)
	{
		ExpressionOwner ew = (ExpressionOwner)paths.elementAt(i);
		assertion(ew != owner, "duplicate owner on the list!!!");
		assertion(ew.getExpression() != path, "duplicate expression on the list!!!");
	}
  }
897084
static void validateValueUniquenessInScope(String qualifiedName,
      List<TypeElement> nestedElements) {
    Set<String> names = new LinkedHashSet<>();
    for (TypeElement nestedElement : nestedElements) {
      if (nestedElement instanceof EnumElement) {
        EnumElement enumElement = (EnumElement) nestedElement;
        for (EnumConstantElement constant : enumElement.constants()) {
          String name = constant.name();
          if (!names.add(name)) {
            throw new IllegalStateException(
                "Duplicate enum constant " + name + " in scope " + qualifiedName);
          }
        }
      }
    }
  }