github.com/searKing/golang/go@v1.2.74/container/slice/allmatch.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package slice 6 7 // AllMatchFunc returns whether all elements of this stream match the provided predicate. 8 // May not evaluate the predicate on all elements if not necessary for 9 // determining the result. If the stream is empty then {@code true} is 10 // returned and the predicate is not evaluated. 11 func AllMatchFunc(s interface{}, f func(interface{}) bool) bool { 12 return allMatchFunc(Of(s), f, true) 13 } 14 15 // allMatchFunc is the same as AllMatchFunc. 16 func allMatchFunc(s []interface{}, f func(interface{}) bool, truth bool) bool { 17 return !anyMatchFunc(s, f, !truth) 18 }