// Difference returns the set difference (A - B) of the two given slices. The
// result will also remove any duplicated values in set A regardless of whether
// that matches any values in set B.
175837
func Difference(a, b []string, lowercase bool) []string {
	if len(a) == 0 {
		return a
	}
	if len(b) == 0 {
		if !lowercase {
			return a
		}
		newA := make([]string, len(a))
		for i, v := range a {
			newA[i] = strings.ToLower(v)
		}
		return newA
	}

	a = RemoveDuplicates(a, lowercase)
	b = RemoveDuplicates(b, lowercase)

	itemsMap := map[string]bool{}
	for _, aVal := range a {
		itemsMap[aVal] = true
	}

	// Perform difference calculation
	for _, bVal := range b {
		if _, ok := itemsMap[bVal]; ok {
			itemsMap[bVal] = false
		}
	}

	items := []string{}
	for item, exists := range itemsMap {
		if exists {
			items = append(items, item)
		}
	}
	sort.Strings(items)
	return items
}
66235
func compare(v1, v2 interface{}, op int) bool {

	var i1, i2 int64
	var ok bool

	i1, ok = _int64(v1)

	if ok {
		i2, ok = _int64f(v2)
		if !ok {
			return false
		}

		switch op {
		case '=':
			return i1 == i2
		case '+':
			return i1 >= i2
		case '-':
			return i1 <= i2
		case '>':
			return i1 > i2
		case '<':
			return i1 < i2
		case '!':
			return i1 != i2
		}
		return false
	}

	var f1, f2 float64

	f1, ok = _float64(v1)
	if ok {
		f2, ok = _float64f(v2)
		if !ok {
			return false
		}
		switch op {
		case '=':
			return f1 == f2
		case '+':
			return f1 >= f2
		case '-':
			return f1 <= f2
		case '>':
			return f1 > f2
		case '<':
			return f1 < f2
		case '!':
			return f1 != f2
		}
		return false
	}

	s1 := _string(v1)
	s2 := _string(v2)

	switch op {
	case '=':
		return s1 == s2
	case '!':
		return s1 != s2
	}
	return false
}
195938
func (s Int) Difference(s2 Int) Int {
	result := NewInt()
	for key := range s {
		if !s2.Has(key) {
			result.Insert(key)
		}
	}
	return result
}
83590
func (s VarSet) Diff(vs VarSet) VarSet {
	r := VarSet{}
	for v := range s {
		if !vs.Contains(v) {
			r.Add(v)
		}
	}
	return r
}
578268
func (rs Ranges) Compare(right Ranges) int {
	x, y, result := rs.equiv(right)
	if result {
		return 0
	}
	for _, a := range x {
		// make sure that this range is a subset of a range in y
		matched := false
		for _, b := range y {
			if a.Begin >= b.Begin && a.End <= b.End {
				matched = true
				break
			}
		}
		if !matched {
			return 1
		}
	}
	return -1
}
1345937
func (list *List) Slice(from, to int) []string {
	if list.length == 0 {
		return emptySlice()
	}
	if from >= list.length || to >= list.length || from < 0 || to < 0 || from > to {
		return emptySlice()
	}
	if from == to {
		return oneSlice(list.Get(from))
	}
	diff := to - from + 1
	result := make([]string, diff)
	tmp := list.first
	for i := 0; i < list.length; i++ {
		if i >= from && i <= to {
			result[i-from] = tmp.Content
		}
		if i >= to {
			break
		}
		tmp = tmp.Next
	}
	return result
}
1239351
func (s *Set) Equal(t *Set) bool {
	return s.Size() == t.Size() && s.Difference(t).Size() == 0
}
1131479
def difference (b, a):
    
    a = set(a)
    result = []
    for item in b:
        if item not in a:
            result.append(item)
    return result
345845
func (t Term) Difference(args ...interface{}) Term {
	return constructMethodTerm(t, "Difference", p.Term_DIFFERENCE, args, map[string]interface{}{})
}
1072395
func (e Entries) Diff(cmp Entries) (Entries, Entries) {
	added := Entries{}
	for _, entry := range cmp {
		if !e.Contains(entry) {
			added = append(added, entry)
		}
	}

	removed := Entries{}
	for _, entry := range e {
		if !cmp.Contains(entry) {
			removed = append(removed, entry)
		}
	}

	return added, removed
}
1104091
func (set LiteralFieldSet) Difference(other LiteralFieldSet) LiteralFieldSet {
	differencedSet := NewLiteralFieldSet()
	for elem := range set {
		if !other.Contains(elem) {
			differencedSet.Add(elem)
		}
	}
	return differencedSet
}
1049741
func (diff *differ) Diff(out io.Writer, a io.ReadSeeker, b io.ReadSeeker) error {
	d, err := readData(a, b)
	if err != nil {
		return err
	}

	changes := d.Diff()
	for _, change := range changes {
		err := d.WriteHunk(out, change, 3)
		if err != nil {
			return err
		}
	}
	return nil
}
127680
func diff(a, b map[string]interface{}, path string, patch []JsonPatchOperation) ([]JsonPatchOperation, error) {
	for key, bv := range b {
		p := makePath(path, key)
		av, ok := a[key]
		// value was added
		if !ok {
			patch = append(patch, NewPatch("add", p, bv))
			continue
		}
		// If types have changed, replace completely
		if reflect.TypeOf(av) != reflect.TypeOf(bv) {
			patch = append(patch, NewPatch("replace", p, bv))
			continue
		}
		// Types are the same, compare values
		var err error
		patch, err = handleValues(av, bv, p, patch)
		if err != nil {
			return nil, err
		}
	}
	// Now add all deleted values as nil
	for key := range a {
		_, found := b[key]
		if !found {
			p := makePath(path, key)

			patch = append(patch, NewPatch("remove", p, nil))
		}
	}
	return patch, nil
}
634351
func Difference(wants []string, haves []string) (revoke []string, add []string) {
	for _, want := range wants {
		found := false
		for _, got := range haves {
			if want != got {
				continue
			}
			found = true
		}
		if !found {
			add = append(add, want)
		}
	}
	for _, got := range haves {
		found := false
		for _, want := range wants {
			if want != got {
				continue
			}
			found = true
			break
		}
		if !found {
			revoke = append(revoke, got)
		}
	}
	return
}
925899
func (s IPPermissionSet) Difference(s2 IPPermissionSet) IPPermissionSet {
	result := NewIPPermissionSet()
	for k, v := range s {
		_, found := s2[k]
		if !found {
			result[k] = v
		}
	}
	return result
}
83184
func (d *MyDecimal) Compare(to *MyDecimal) int {
	if d.negative == to.negative {
		cmp, err := doSub(d, to, nil)
		terror.Log(errors.Trace(err))
		return cmp
	}
	if d.negative {
		return -1
	}
	return 1
}
907579
func (a FileLayerAnalyzer) Diff(image1, image2 pkgutil.Image) (util.Result, error) {
	var dirDiffs []util.DirDiff

	// Go through each layer of the first image...
	for index, layer := range image1.Layers {
		if index >= len(image2.Layers) {
			continue
		}
		// ...else, diff as usual
		layer2 := image2.Layers[index]
		diff, err := diffImageFiles(layer.FSPath, layer2.FSPath)
		if err != nil {
			return &util.MultipleDirDiffResult{}, err
		}
		dirDiffs = append(dirDiffs, diff)
	}

	// check if there are any additional layers in either image
	if len(image1.Layers) != len(image2.Layers) {
		if len(image1.Layers) > len(image2.Layers) {
			logrus.Infof("%s has additional layers, please use container-diff analyze to view the files in these layers", image1.Source)
		} else {
			logrus.Infof("%s has additional layers, please use container-diff analyze to view the files in these layers", image2.Source)
		}
	}
	return &util.MultipleDirDiffResult{
		Image1:   image1.Source,
		Image2:   image2.Source,
		DiffType: "FileLayer",
		Diff: util.MultipleDirDiff{
			DirDiffs: dirDiffs,
		},
	}, nil
}