1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-12 08:42:29 +08:00

feat: add func ContainSubSlice

This commit is contained in:
dudaodong
2022-01-13 11:52:21 +08:00
6 changed files with 57 additions and 5 deletions

View File

@@ -5,6 +5,31 @@ import (
"reflect"
)
// func quickSort[T comparable](slice []T, low, high int) []T {
// if low < high {
// var p int
// slice, p = partitionForQuickSort(slice, low, high)
// slice = quickSort(slice, low, p-1)
// slice = quickSort(slice, p+1, high)
// }
// return slice
// }
// func partitionForQuickSort[T comparable](slice []T, low, high int) ([]T, int) {
// p := slice[high]
// i := low
// for j := low; j < high; j++ {
// //???, error: comparable don't support operator <
// if slice[j] < p {
// slice[i], slice[j] = slice[j], slice[i]
// i++
// }
// }
// slice[i], slice[high] = slice[high], slice[i]
// return slice, i
// }
// sliceValue return the reflect value of a slice
func sliceValue(slice interface{}) reflect.Value {
v := reflect.ValueOf(slice)