Restore old obisort and add LCA functionnality to obiannotate.

Former-commit-id: aecaacc9dae49f74bd888a8eb8140822d31a42a6
This commit is contained in:
2023-05-02 10:43:22 +02:00
parent e9dcacbf24
commit 60c187404d
5 changed files with 190 additions and 6 deletions

View File

@ -21,3 +21,16 @@ func LookFor[T comparable](arr []T, x T) int {
func RemoveIndex[T comparable](s []T, index int) []T {
return append(s[:index], s[index+1:]...)
}
func Reverse[S ~[]E, E any](s S, inplace bool) S {
if !inplace {
c := make([]E,len(s))
copy(c,s)
s = c
}
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
return s
}