File: primitives.go

package info (click to toggle)
golang-github-xtgo-set 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 148 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 529 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2015 Kevin Gillette. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package set

import "sort"

func xcopy(data sort.Interface, i, j, k, l int) int {
	for i < k && j < l {
		data.Swap(i, j)
		i, j = i+1, j+1
	}
	return i
}

func slide(data sort.Interface, i, j, n int) {
	xcopy(data, i, j, i+n, j+n)
}

/*
func find(data sort.Interface, x, i, j int) int {
	return sort.Search(j-i, func(y int) bool {
		return !data.Less(x, i+y)
	})
}
*/