I'm reasonably happy with this. I started with a bi-directional linked list, but realized that a flat list of all nodes came in handy for one use case while the linked list came in handy for another, so I settled on that.
13 lines
241 B
Go
13 lines
241 B
Go
package utilities
|
|
|
|
// ArrayContains returns whether the specified array contains the specified value
|
|
func ArrayContains[T comparable](array []T, val T) bool {
|
|
for _, v := range array {
|
|
if v == val {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|