remove the O(n*n) addUnique one from std (#22799)

It's not used in the compiler, besides, it doesn't seem to be a common
operation. Follows the discussion on the Discord.
This commit is contained in:
ringabout
2023-10-07 04:39:32 +08:00
committed by GitHub
parent f2f0b3e25d
commit 476492583b

View File

@@ -157,18 +157,6 @@ func addUnique*[T](s: var seq[T], x: sink T) =
else:
s.add x
func addUnique*[T](s: var seq[T], xs: sink seq[T]) =
## Adds any items from `xs` to the container `s` that are not already present.
## Uses `==` to check if the item is already present.
runnableExamples:
var a = @[1, 2, 3]
a.addUnique(@[3, 4])
a.addUnique(@[4, 5])
assert a == @[1, 2, 3, 4, 5]
for i in 0..high(xs):
addUnique(s, move(xs[i]))
func count*[T](s: openArray[T], x: T): int =
## Returns the number of occurrences of the item `x` in the container `s`.
##