Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- func Collect[T any, S Enumerator[T]](iter S) []T
- func Count[T any, S Enumerator[T]](iter S) uint
- func Find[T any, S Enumerator[T]](iter S, predicate Predicate[T]) (uint, bool)
- func Nth[T any, S Enumerator[T]](iter S, n uint) T
- type Enumerator
- func Append[T any](enumerators ...Enumerator[T]) Enumerator[T]
- func ExhaustiveSample[T any](n uint, enum Enumerator[T]) Enumerator[T]
- func FastSample[T any](n uint, enum Enumerator[T]) Enumerator[T]
- func Finite[T any](items ...T) Enumerator[T]
- func Power[E any](n uint, elems []E) Enumerator[[]E]
- func Range[T any](start uint, end uint) Enumerator[uint]
- type Predicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Collect ¶
func Collect[T any, S Enumerator[T]](iter S) []T
Collect provides a default implementation of Iterator.Collect which can be used by other iterator implementations.
func Count ¶
func Count[T any, S Enumerator[T]](iter S) uint
Count provides a default implementation of Iterator.Count which can be used by other iterator implementations.
func Find ¶
func Find[T any, S Enumerator[T]](iter S, predicate Predicate[T]) (uint, bool)
Find provides a default implementation of Iterator.Find which can be used by other iterator implementations.
func Nth ¶
func Nth[T any, S Enumerator[T]](iter S, n uint) T
Nth provides a default implementation of Iterator.Nth which can be used by other iterator implementations.
Types ¶
type Enumerator ¶
type Enumerator[T any] interface { // Check whether or not there are any items remaining to visit. HasNext() bool // Get the next item, and advanced the iterator. Next() T // Get the nth item in this iterator, where 0 refers to the next items, 1 to // the item after that, etc. This will mutate the iterator. Nth(uint) T // Count the number of items left. Note, this does not modify the iterator. Count() uint }
Enumerator abstracts the process of iterating over a sequence of elements.
func Append ¶
func Append[T any](enumerators ...Enumerator[T]) Enumerator[T]
Append constructs an enumerator from an array of zero or more enumerators.
func ExhaustiveSample ¶ added in v1.1.14
func ExhaustiveSample[T any](n uint, enum Enumerator[T]) Enumerator[T]
ExhaustiveSample constructs a sampling enumerator from a given enumerator. Specifically, the sampling enumerator samples exactly n items from the given enumerator (assuming it held at least n items). Otherwise, if n is larger or equal to the number of elements in the original numerator it simply returns that.
func FastSample ¶ added in v1.1.14
func FastSample[T any](n uint, enum Enumerator[T]) Enumerator[T]
FastSample does as it says on the tin. Its fast, but not super precise. For example, duplicates are possible.
func Finite ¶ added in v1.1.14
func Finite[T any](items ...T) Enumerator[T]
Finite constructs an enumerator over a finite number of items.
func Power ¶
func Power[E any](n uint, elems []E) Enumerator[[]E]
Power returns an iterator which enumerates all arrays of size n over the given set of elements. For example, if n==2 and elems contained two elements A and B, then this will return [[A,A],[A,B],[B,A],[B,B]].